<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - /usr/include/opencv2/core/mat.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../index.html">top level</a> - <a href="index.html">usr/include/opencv2/core</a> - mat.hpp<span style="font-size: 80%;"> (source / <a href="mat.hpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">57</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:50:33</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">4</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : /*M///////////////////////////////////////////////////////////////////////////////////////</a>
<span class="lineNum">       2 </span>            : //
<span class="lineNum">       3 </span>            : //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
<span class="lineNum">       4 </span>            : //
<span class="lineNum">       5 </span>            : //  By downloading, copying, installing or using the software you agree to this license.
<span class="lineNum">       6 </span>            : //  If you do not agree to this license, do not download, install,
<span class="lineNum">       7 </span>            : //  copy or use the software.
<span class="lineNum">       8 </span>            : //
<span class="lineNum">       9 </span>            : //
<span class="lineNum">      10 </span>            : //                           License Agreement
<span class="lineNum">      11 </span>            : //                For Open Source Computer Vision Library
<span class="lineNum">      12 </span>            : //
<span class="lineNum">      13 </span>            : // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
<span class="lineNum">      14 </span>            : // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
<span class="lineNum">      15 </span>            : // Third party copyrights are property of their respective owners.
<span class="lineNum">      16 </span>            : //
<span class="lineNum">      17 </span>            : // Redistribution and use in source and binary forms, with or without modification,
<span class="lineNum">      18 </span>            : // are permitted provided that the following conditions are met:
<span class="lineNum">      19 </span>            : //
<span class="lineNum">      20 </span>            : //   * Redistribution's of source code must retain the above copyright notice,
<span class="lineNum">      21 </span>            : //     this list of conditions and the following disclaimer.
<span class="lineNum">      22 </span>            : //
<span class="lineNum">      23 </span>            : //   * Redistribution's in binary form must reproduce the above copyright notice,
<span class="lineNum">      24 </span>            : //     this list of conditions and the following disclaimer in the documentation
<span class="lineNum">      25 </span>            : //     and/or other materials provided with the distribution.
<span class="lineNum">      26 </span>            : //
<span class="lineNum">      27 </span>            : //   * The name of the copyright holders may not be used to endorse or promote products
<span class="lineNum">      28 </span>            : //     derived from this software without specific prior written permission.
<span class="lineNum">      29 </span>            : //
<span class="lineNum">      30 </span>            : // This software is provided by the copyright holders and contributors &quot;as is&quot; and
<span class="lineNum">      31 </span>            : // any express or implied warranties, including, but not limited to, the implied
<span class="lineNum">      32 </span>            : // warranties of merchantability and fitness for a particular purpose are disclaimed.
<span class="lineNum">      33 </span>            : // In no event shall the Intel Corporation or contributors be liable for any direct,
<span class="lineNum">      34 </span>            : // indirect, incidental, special, exemplary, or consequential damages
<span class="lineNum">      35 </span>            : // (including, but not limited to, procurement of substitute goods or services;
<span class="lineNum">      36 </span>            : // loss of use, data, or profits; or business interruption) however caused
<span class="lineNum">      37 </span>            : // and on any theory of liability, whether in contract, strict liability,
<span class="lineNum">      38 </span>            : // or tort (including negligence or otherwise) arising in any way out of
<span class="lineNum">      39 </span>            : // the use of this software, even if advised of the possibility of such damage.
<span class="lineNum">      40 </span>            : //
<span class="lineNum">      41 </span>            : //M*/
<span class="lineNum">      42 </span>            : 
<span class="lineNum">      43 </span>            : #ifndef __OPENCV_CORE_MATRIX_OPERATIONS_HPP__
<span class="lineNum">      44 </span>            : #define __OPENCV_CORE_MATRIX_OPERATIONS_HPP__
<span class="lineNum">      45 </span>            : 
<span class="lineNum">      46 </span>            : #ifndef SKIP_INCLUDES
<span class="lineNum">      47 </span>            : #include &lt;limits.h&gt;
<span class="lineNum">      48 </span>            : #include &lt;string.h&gt;
<span class="lineNum">      49 </span>            : #endif // SKIP_INCLUDES
<span class="lineNum">      50 </span>            : 
<span class="lineNum">      51 </span>            : #ifdef __cplusplus
<span class="lineNum">      52 </span>            : 
<span class="lineNum">      53 </span>            : namespace cv
<span class="lineNum">      54 </span>            : {
<span class="lineNum">      55 </span>            : 
<span class="lineNum">      56 </span>            : //////////////////////////////// Mat ////////////////////////////////
<span class="lineNum">      57 </span>            : 
<span class="lineNum">      58 </span>            : inline void Mat::initEmpty()
<span class="lineNum">      59 </span>            : {
<span class="lineNum">      60 </span><span class="lineNoCov">          0 :     flags = MAGIC_VAL;</span>
<span class="lineNum">      61 </span><span class="lineNoCov">          0 :     dims = rows = cols = 0;</span>
<span class="lineNum">      62 </span><span class="lineNoCov">          0 :     data = datastart = dataend = datalimit = 0;</span>
<span class="lineNum">      63 </span><span class="lineNoCov">          0 :     refcount = 0;</span>
<span class="lineNum">      64 </span><span class="lineNoCov">          0 :     allocator = 0;</span>
<span class="lineNum">      65 </span>            : }
<span class="lineNum">      66 </span>            : 
<span class="lineNum">      67 </span><span class="lineNoCov">          0 : inline Mat::Mat() : size(&amp;rows)</span>
<span class="lineNum">      68 </span>            : {
<span class="lineNum">      69 </span>            :     initEmpty();
<span class="lineNum">      70 </span>            : }
<span class="lineNum">      71 </span>            : 
<span class="lineNum">      72 </span>            : inline Mat::Mat(int _rows, int _cols, int _type) : size(&amp;rows)
<span class="lineNum">      73 </span>            : {
<span class="lineNum">      74 </span>            :     initEmpty();
<span class="lineNum">      75 </span>            :     create(_rows, _cols, _type);
<span class="lineNum">      76 </span>            : }
<span class="lineNum">      77 </span>            : 
<span class="lineNum">      78 </span>            : inline Mat::Mat(int _rows, int _cols, int _type, const Scalar&amp; _s) : size(&amp;rows)
<span class="lineNum">      79 </span>            : {
<span class="lineNum">      80 </span>            :     initEmpty();
<span class="lineNum">      81 </span>            :     create(_rows, _cols, _type);
<span class="lineNum">      82 </span>            :     *this = _s;
<span class="lineNum">      83 </span>            : }
<span class="lineNum">      84 </span>            : 
<span class="lineNum">      85 </span>            : inline Mat::Mat(Size _sz, int _type) : size(&amp;rows)
<span class="lineNum">      86 </span>            : {
<span class="lineNum">      87 </span>            :     initEmpty();
<span class="lineNum">      88 </span>            :     create( _sz.height, _sz.width, _type );
<span class="lineNum">      89 </span>            : }
<span class="lineNum">      90 </span>            : 
<span class="lineNum">      91 </span>            : inline Mat::Mat(Size _sz, int _type, const Scalar&amp; _s) : size(&amp;rows)
<span class="lineNum">      92 </span>            : {
<span class="lineNum">      93 </span>            :     initEmpty();
<span class="lineNum">      94 </span>            :     create(_sz.height, _sz.width, _type);
<span class="lineNum">      95 </span>            :     *this = _s;
<span class="lineNum">      96 </span>            : }
<span class="lineNum">      97 </span>            : 
<span class="lineNum">      98 </span>            : inline Mat::Mat(int _dims, const int* _sz, int _type) : size(&amp;rows)
<span class="lineNum">      99 </span>            : {
<span class="lineNum">     100 </span>            :     initEmpty();
<span class="lineNum">     101 </span>            :     create(_dims, _sz, _type);
<span class="lineNum">     102 </span>            : }
<span class="lineNum">     103 </span>            : 
<span class="lineNum">     104 </span>            : inline Mat::Mat(int _dims, const int* _sz, int _type, const Scalar&amp; _s) : size(&amp;rows)
<span class="lineNum">     105 </span>            : {
<span class="lineNum">     106 </span>            :     initEmpty();
<span class="lineNum">     107 </span>            :     create(_dims, _sz, _type);
<span class="lineNum">     108 </span>            :     *this = _s;
<a name="109"><span class="lineNum">     109 </span>            : }</a>
<span class="lineNum">     110 </span>            : 
<span class="lineNum">     111 </span><span class="lineNoCov">          0 : inline Mat::Mat(const Mat&amp; m)</span>
<span class="lineNum">     112 </span><span class="lineNoCov">          0 :     : flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data),</span>
<span class="lineNum">     113 </span><span class="lineNoCov">          0 :     refcount(m.refcount), datastart(m.datastart), dataend(m.dataend),</span>
<span class="lineNum">     114 </span><span class="lineNoCov">          0 :     datalimit(m.datalimit), allocator(m.allocator), size(&amp;rows)</span>
<span class="lineNum">     115 </span>            : {
<span class="lineNum">     116 </span><span class="lineNoCov">          0 :     if( refcount )</span>
<span class="lineNum">     117 </span><span class="lineNoCov">          0 :         CV_XADD(refcount, 1);</span>
<span class="lineNum">     118 </span><span class="lineNoCov">          0 :     if( m.dims &lt;= 2 )</span>
<span class="lineNum">     119 </span>            :     {
<span class="lineNum">     120 </span><span class="lineNoCov">          0 :         step[0] = m.step[0]; step[1] = m.step[1];</span>
<span class="lineNum">     121 </span>            :     }
<span class="lineNum">     122 </span>            :     else
<span class="lineNum">     123 </span>            :     {
<span class="lineNum">     124 </span><span class="lineNoCov">          0 :         dims = 0;</span>
<span class="lineNum">     125 </span><span class="lineNoCov">          0 :         copySize(m);</span>
<span class="lineNum">     126 </span>            :     }
<span class="lineNum">     127 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     128 </span>            : 
<span class="lineNum">     129 </span>            : inline Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step)
<span class="lineNum">     130 </span>            :     : flags(MAGIC_VAL + (_type &amp; TYPE_MASK)), dims(2), rows(_rows), cols(_cols),
<span class="lineNum">     131 </span>            :     data((uchar*)_data), refcount(0), datastart((uchar*)_data), dataend(0),
<span class="lineNum">     132 </span>            :     datalimit(0), allocator(0), size(&amp;rows)
<span class="lineNum">     133 </span>            : {
<span class="lineNum">     134 </span>            :     size_t esz = CV_ELEM_SIZE(_type), minstep = cols*esz;
<span class="lineNum">     135 </span>            :     if( _step == AUTO_STEP )
<span class="lineNum">     136 </span>            :     {
<span class="lineNum">     137 </span>            :         _step = minstep;
<span class="lineNum">     138 </span>            :         flags |= CONTINUOUS_FLAG;
<span class="lineNum">     139 </span>            :     }
<span class="lineNum">     140 </span>            :     else
<span class="lineNum">     141 </span>            :     {
<span class="lineNum">     142 </span>            :         if( rows == 1 ) _step = minstep;
<span class="lineNum">     143 </span>            :         CV_DbgAssert( _step &gt;= minstep );
<span class="lineNum">     144 </span>            :         flags |= _step == minstep ? CONTINUOUS_FLAG : 0;
<span class="lineNum">     145 </span>            :     }
<span class="lineNum">     146 </span>            :     step[0] = _step; step[1] = esz;
<span class="lineNum">     147 </span>            :     datalimit = datastart + _step*rows;
<span class="lineNum">     148 </span>            :     dataend = datalimit - _step + minstep;
<span class="lineNum">     149 </span>            : }
<span class="lineNum">     150 </span>            : 
<span class="lineNum">     151 </span>            : inline Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
<span class="lineNum">     152 </span>            :     : flags(MAGIC_VAL + (_type &amp; TYPE_MASK)), dims(2), rows(_sz.height), cols(_sz.width),
<span class="lineNum">     153 </span>            :     data((uchar*)_data), refcount(0), datastart((uchar*)_data), dataend(0),
<span class="lineNum">     154 </span>            :     datalimit(0), allocator(0), size(&amp;rows)
<span class="lineNum">     155 </span>            : {
<span class="lineNum">     156 </span>            :     size_t esz = CV_ELEM_SIZE(_type), minstep = cols*esz;
<span class="lineNum">     157 </span>            :     if( _step == AUTO_STEP )
<span class="lineNum">     158 </span>            :     {
<span class="lineNum">     159 </span>            :         _step = minstep;
<span class="lineNum">     160 </span>            :         flags |= CONTINUOUS_FLAG;
<span class="lineNum">     161 </span>            :     }
<span class="lineNum">     162 </span>            :     else
<span class="lineNum">     163 </span>            :     {
<span class="lineNum">     164 </span>            :         if( rows == 1 ) _step = minstep;
<span class="lineNum">     165 </span>            :         CV_DbgAssert( _step &gt;= minstep );
<span class="lineNum">     166 </span>            :         flags |= _step == minstep ? CONTINUOUS_FLAG : 0;
<span class="lineNum">     167 </span>            :     }
<span class="lineNum">     168 </span>            :     step[0] = _step; step[1] = esz;
<span class="lineNum">     169 </span>            :     datalimit = datastart + _step*rows;
<span class="lineNum">     170 </span>            :     dataend = datalimit - _step + minstep;
<span class="lineNum">     171 </span>            : }
<span class="lineNum">     172 </span>            : 
<span class="lineNum">     173 </span>            : 
<span class="lineNum">     174 </span>            : template&lt;typename _Tp&gt; inline Mat::Mat(const vector&lt;_Tp&gt;&amp; vec, bool copyData)
<span class="lineNum">     175 </span>            :     : flags(MAGIC_VAL | DataType&lt;_Tp&gt;::type | CV_MAT_CONT_FLAG),
<span class="lineNum">     176 </span>            :     dims(2), rows((int)vec.size()), cols(1), data(0), refcount(0),
<span class="lineNum">     177 </span>            :     datastart(0), dataend(0), allocator(0), size(&amp;rows)
<span class="lineNum">     178 </span>            : {
<span class="lineNum">     179 </span>            :     if(vec.empty())
<span class="lineNum">     180 </span>            :         return;
<span class="lineNum">     181 </span>            :     if( !copyData )
<span class="lineNum">     182 </span>            :     {
<span class="lineNum">     183 </span>            :         step[0] = step[1] = sizeof(_Tp);
<span class="lineNum">     184 </span>            :         data = datastart = (uchar*)&amp;vec[0];
<span class="lineNum">     185 </span>            :         datalimit = dataend = datastart + rows*step[0];
<span class="lineNum">     186 </span>            :     }
<span class="lineNum">     187 </span>            :     else
<span class="lineNum">     188 </span>            :         Mat((int)vec.size(), 1, DataType&lt;_Tp&gt;::type, (uchar*)&amp;vec[0]).copyTo(*this);
<span class="lineNum">     189 </span>            : }
<span class="lineNum">     190 </span>            : 
<span class="lineNum">     191 </span>            : 
<span class="lineNum">     192 </span>            : template&lt;typename _Tp, int n&gt; inline Mat::Mat(const Vec&lt;_Tp, n&gt;&amp; vec, bool copyData)
<span class="lineNum">     193 </span>            :     : flags(MAGIC_VAL | DataType&lt;_Tp&gt;::type | CV_MAT_CONT_FLAG),
<span class="lineNum">     194 </span>            :     dims(2), rows(n), cols(1), data(0), refcount(0),
<span class="lineNum">     195 </span>            :     datastart(0), dataend(0), allocator(0), size(&amp;rows)
<span class="lineNum">     196 </span>            : {
<span class="lineNum">     197 </span>            :     if( !copyData )
<span class="lineNum">     198 </span>            :     {
<span class="lineNum">     199 </span>            :         step[0] = step[1] = sizeof(_Tp);
<span class="lineNum">     200 </span>            :         data = datastart = (uchar*)vec.val;
<span class="lineNum">     201 </span>            :         datalimit = dataend = datastart + rows*step[0];
<span class="lineNum">     202 </span>            :     }
<span class="lineNum">     203 </span>            :     else
<span class="lineNum">     204 </span>            :         Mat(n, 1, DataType&lt;_Tp&gt;::type, (void*)vec.val).copyTo(*this);
<span class="lineNum">     205 </span>            : }
<span class="lineNum">     206 </span>            : 
<span class="lineNum">     207 </span>            : 
<span class="lineNum">     208 </span>            : template&lt;typename _Tp, int m, int n&gt; inline Mat::Mat(const Matx&lt;_Tp,m,n&gt;&amp; M, bool copyData)
<span class="lineNum">     209 </span>            :     : flags(MAGIC_VAL | DataType&lt;_Tp&gt;::type | CV_MAT_CONT_FLAG),
<span class="lineNum">     210 </span>            :     dims(2), rows(m), cols(n), data(0), refcount(0),
<span class="lineNum">     211 </span>            :     datastart(0), dataend(0), allocator(0), size(&amp;rows)
<span class="lineNum">     212 </span>            : {
<span class="lineNum">     213 </span>            :     if( !copyData )
<span class="lineNum">     214 </span>            :     {
<span class="lineNum">     215 </span>            :         step[0] = cols*sizeof(_Tp);
<span class="lineNum">     216 </span>            :         step[1] = sizeof(_Tp);
<span class="lineNum">     217 </span>            :         data = datastart = (uchar*)M.val;
<span class="lineNum">     218 </span>            :         datalimit = dataend = datastart + rows*step[0];
<span class="lineNum">     219 </span>            :     }
<span class="lineNum">     220 </span>            :     else
<span class="lineNum">     221 </span>            :         Mat(m, n, DataType&lt;_Tp&gt;::type, (uchar*)M.val).copyTo(*this);
<span class="lineNum">     222 </span>            : }
<span class="lineNum">     223 </span>            : 
<span class="lineNum">     224 </span>            : 
<span class="lineNum">     225 </span>            : template&lt;typename _Tp&gt; inline Mat::Mat(const Point_&lt;_Tp&gt;&amp; pt, bool copyData)
<span class="lineNum">     226 </span>            :     : flags(MAGIC_VAL | DataType&lt;_Tp&gt;::type | CV_MAT_CONT_FLAG),
<span class="lineNum">     227 </span>            :     dims(2), rows(2), cols(1), data(0), refcount(0),
<span class="lineNum">     228 </span>            :     datastart(0), dataend(0), allocator(0), size(&amp;rows)
<span class="lineNum">     229 </span>            : {
<span class="lineNum">     230 </span>            :     if( !copyData )
<span class="lineNum">     231 </span>            :     {
<span class="lineNum">     232 </span>            :         step[0] = step[1] = sizeof(_Tp);
<span class="lineNum">     233 </span>            :         data = datastart = (uchar*)&amp;pt.x;
<span class="lineNum">     234 </span>            :         datalimit = dataend = datastart + rows*step[0];
<span class="lineNum">     235 </span>            :     }
<span class="lineNum">     236 </span>            :     else
<span class="lineNum">     237 </span>            :     {
<span class="lineNum">     238 </span>            :         create(2, 1, DataType&lt;_Tp&gt;::type);
<span class="lineNum">     239 </span>            :         ((_Tp*)data)[0] = pt.x;
<span class="lineNum">     240 </span>            :         ((_Tp*)data)[1] = pt.y;
<span class="lineNum">     241 </span>            :     }
<span class="lineNum">     242 </span>            : }
<span class="lineNum">     243 </span>            : 
<span class="lineNum">     244 </span>            : 
<span class="lineNum">     245 </span>            : template&lt;typename _Tp&gt; inline Mat::Mat(const Point3_&lt;_Tp&gt;&amp; pt, bool copyData)
<span class="lineNum">     246 </span>            :     : flags(MAGIC_VAL | DataType&lt;_Tp&gt;::type | CV_MAT_CONT_FLAG),
<span class="lineNum">     247 </span>            :     dims(2), rows(3), cols(1), data(0), refcount(0),
<span class="lineNum">     248 </span>            :     datastart(0), dataend(0), allocator(0), size(&amp;rows)
<span class="lineNum">     249 </span>            : {
<span class="lineNum">     250 </span>            :     if( !copyData )
<span class="lineNum">     251 </span>            :     {
<span class="lineNum">     252 </span>            :         step[0] = step[1] = sizeof(_Tp);
<span class="lineNum">     253 </span>            :         data = datastart = (uchar*)&amp;pt.x;
<span class="lineNum">     254 </span>            :         datalimit = dataend = datastart + rows*step[0];
<span class="lineNum">     255 </span>            :     }
<span class="lineNum">     256 </span>            :     else
<span class="lineNum">     257 </span>            :     {
<span class="lineNum">     258 </span>            :         create(3, 1, DataType&lt;_Tp&gt;::type);
<span class="lineNum">     259 </span>            :         ((_Tp*)data)[0] = pt.x;
<span class="lineNum">     260 </span>            :         ((_Tp*)data)[1] = pt.y;
<span class="lineNum">     261 </span>            :         ((_Tp*)data)[2] = pt.z;
<span class="lineNum">     262 </span>            :     }
<span class="lineNum">     263 </span>            : }
<span class="lineNum">     264 </span>            : 
<span class="lineNum">     265 </span>            : 
<span class="lineNum">     266 </span>            : template&lt;typename _Tp&gt; inline Mat::Mat(const MatCommaInitializer_&lt;_Tp&gt;&amp; commaInitializer)
<span class="lineNum">     267 </span>            :     : flags(MAGIC_VAL | DataType&lt;_Tp&gt;::type | CV_MAT_CONT_FLAG),
<span class="lineNum">     268 </span>            :     dims(0), rows(0), cols(0), data(0), refcount(0),
<span class="lineNum">     269 </span>            :     datastart(0), dataend(0), allocator(0), size(&amp;rows)
<span class="lineNum">     270 </span>            : {
<span class="lineNum">     271 </span>            :     *this = *commaInitializer;
<a name="272"><span class="lineNum">     272 </span>            : }</a>
<span class="lineNum">     273 </span>            : 
<span class="lineNum">     274 </span><span class="lineNoCov">          0 : inline Mat::~Mat()</span>
<span class="lineNum">     275 </span>            : {
<span class="lineNum">     276 </span><span class="lineNoCov">          0 :     release();</span>
<span class="lineNum">     277 </span><span class="lineNoCov">          0 :     if( step.p != step.buf )</span>
<span class="lineNum">     278 </span><span class="lineNoCov">          0 :         fastFree(step.p);</span>
<a name="279"><span class="lineNum">     279 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">     280 </span>            : 
<span class="lineNum">     281 </span><span class="lineNoCov">          0 : inline Mat&amp; Mat::operator = (const Mat&amp; m)</span>
<span class="lineNum">     282 </span>            : {
<span class="lineNum">     283 </span><span class="lineNoCov">          0 :     if( this != &amp;m )</span>
<span class="lineNum">     284 </span>            :     {
<span class="lineNum">     285 </span><span class="lineNoCov">          0 :         if( m.refcount )</span>
<span class="lineNum">     286 </span><span class="lineNoCov">          0 :             CV_XADD(m.refcount, 1);</span>
<span class="lineNum">     287 </span><span class="lineNoCov">          0 :         release();</span>
<span class="lineNum">     288 </span><span class="lineNoCov">          0 :         flags = m.flags;</span>
<span class="lineNum">     289 </span><span class="lineNoCov">          0 :         if( dims &lt;= 2 &amp;&amp; m.dims &lt;= 2 )</span>
<span class="lineNum">     290 </span>            :         {
<span class="lineNum">     291 </span><span class="lineNoCov">          0 :             dims = m.dims;</span>
<span class="lineNum">     292 </span><span class="lineNoCov">          0 :             rows = m.rows;</span>
<span class="lineNum">     293 </span><span class="lineNoCov">          0 :             cols = m.cols;</span>
<span class="lineNum">     294 </span><span class="lineNoCov">          0 :             step[0] = m.step[0];</span>
<span class="lineNum">     295 </span><span class="lineNoCov">          0 :             step[1] = m.step[1];</span>
<span class="lineNum">     296 </span>            :         }
<span class="lineNum">     297 </span>            :         else
<span class="lineNum">     298 </span><span class="lineNoCov">          0 :             copySize(m);</span>
<span class="lineNum">     299 </span><span class="lineNoCov">          0 :         data = m.data;</span>
<span class="lineNum">     300 </span><span class="lineNoCov">          0 :         datastart = m.datastart;</span>
<span class="lineNum">     301 </span><span class="lineNoCov">          0 :         dataend = m.dataend;</span>
<span class="lineNum">     302 </span><span class="lineNoCov">          0 :         datalimit = m.datalimit;</span>
<span class="lineNum">     303 </span><span class="lineNoCov">          0 :         refcount = m.refcount;</span>
<span class="lineNum">     304 </span><span class="lineNoCov">          0 :         allocator = m.allocator;</span>
<span class="lineNum">     305 </span>            :     }
<span class="lineNum">     306 </span><span class="lineNoCov">          0 :     return *this;</span>
<span class="lineNum">     307 </span>            : }
<span class="lineNum">     308 </span>            : 
<span class="lineNum">     309 </span>            : inline Mat Mat::row(int y) const { return Mat(*this, Range(y, y+1), Range::all()); }
<span class="lineNum">     310 </span>            : inline Mat Mat::col(int x) const { return Mat(*this, Range::all(), Range(x, x+1)); }
<span class="lineNum">     311 </span>            : inline Mat Mat::rowRange(int startrow, int endrow) const
<span class="lineNum">     312 </span>            :     { return Mat(*this, Range(startrow, endrow), Range::all()); }
<span class="lineNum">     313 </span>            : inline Mat Mat::rowRange(const Range&amp; r) const
<span class="lineNum">     314 </span>            :     { return Mat(*this, r, Range::all()); }
<span class="lineNum">     315 </span>            : inline Mat Mat::colRange(int startcol, int endcol) const
<span class="lineNum">     316 </span>            :     { return Mat(*this, Range::all(), Range(startcol, endcol)); }
<span class="lineNum">     317 </span>            : inline Mat Mat::colRange(const Range&amp; r) const
<span class="lineNum">     318 </span>            :     { return Mat(*this, Range::all(), r); }
<span class="lineNum">     319 </span>            : 
<span class="lineNum">     320 </span>            : inline Mat Mat::diag(const Mat&amp; d)
<span class="lineNum">     321 </span>            : {
<span class="lineNum">     322 </span>            :     CV_Assert( d.cols == 1 || d.rows == 1 );
<span class="lineNum">     323 </span>            :     int len = d.rows + d.cols - 1;
<span class="lineNum">     324 </span>            :     Mat m(len, len, d.type(), Scalar(0)), md = m.diag();
<span class="lineNum">     325 </span>            :     if( d.cols == 1 )
<span class="lineNum">     326 </span>            :         d.copyTo(md);
<span class="lineNum">     327 </span>            :     else
<span class="lineNum">     328 </span>            :         transpose(d, md);
<span class="lineNum">     329 </span>            :     return m;
<span class="lineNum">     330 </span>            : }
<span class="lineNum">     331 </span>            : 
<span class="lineNum">     332 </span>            : inline Mat Mat::clone() const
<span class="lineNum">     333 </span>            : {
<span class="lineNum">     334 </span>            :     Mat m;
<span class="lineNum">     335 </span>            :     copyTo(m);
<span class="lineNum">     336 </span>            :     return m;
<span class="lineNum">     337 </span>            : }
<span class="lineNum">     338 </span>            : 
<span class="lineNum">     339 </span>            : inline void Mat::assignTo( Mat&amp; m, int _type ) const
<span class="lineNum">     340 </span>            : {
<span class="lineNum">     341 </span>            :     if( _type &lt; 0 )
<span class="lineNum">     342 </span>            :         m = *this;
<span class="lineNum">     343 </span>            :     else
<span class="lineNum">     344 </span>            :         convertTo(m, _type);
<span class="lineNum">     345 </span>            : }
<span class="lineNum">     346 </span>            : 
<span class="lineNum">     347 </span>            : inline void Mat::create(int _rows, int _cols, int _type)
<span class="lineNum">     348 </span>            : {
<span class="lineNum">     349 </span>            :     _type &amp;= TYPE_MASK;
<span class="lineNum">     350 </span>            :     if( dims &lt;= 2 &amp;&amp; rows == _rows &amp;&amp; cols == _cols &amp;&amp; type() == _type &amp;&amp; data )
<span class="lineNum">     351 </span>            :         return;
<span class="lineNum">     352 </span>            :     int sz[] = {_rows, _cols};
<span class="lineNum">     353 </span>            :     create(2, sz, _type);
<span class="lineNum">     354 </span>            : }
<span class="lineNum">     355 </span>            : 
<span class="lineNum">     356 </span>            : inline void Mat::create(Size _sz, int _type)
<span class="lineNum">     357 </span>            : {
<span class="lineNum">     358 </span>            :     create(_sz.height, _sz.width, _type);
<span class="lineNum">     359 </span>            : }
<span class="lineNum">     360 </span>            : 
<span class="lineNum">     361 </span>            : inline void Mat::addref()
<a name="362"><span class="lineNum">     362 </span>            : { if( refcount ) CV_XADD(refcount, 1); }</a>
<span class="lineNum">     363 </span>            : 
<span class="lineNum">     364 </span><span class="lineNoCov">          0 : inline void Mat::release()</span>
<span class="lineNum">     365 </span>            : {
<span class="lineNum">     366 </span><span class="lineNoCov">          0 :     if( refcount &amp;&amp; CV_XADD(refcount, -1) == 1 )</span>
<span class="lineNum">     367 </span><span class="lineNoCov">          0 :         deallocate();</span>
<span class="lineNum">     368 </span><span class="lineNoCov">          0 :     data = datastart = dataend = datalimit = 0;</span>
<span class="lineNum">     369 </span><span class="lineNoCov">          0 :     size.p[0] = 0;</span>
<span class="lineNum">     370 </span><span class="lineNoCov">          0 :     refcount = 0;</span>
<span class="lineNum">     371 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     372 </span>            : 
<span class="lineNum">     373 </span>            : inline Mat Mat::operator()( Range _rowRange, Range _colRange ) const
<span class="lineNum">     374 </span>            : {
<span class="lineNum">     375 </span>            :     return Mat(*this, _rowRange, _colRange);
<span class="lineNum">     376 </span>            : }
<span class="lineNum">     377 </span>            : 
<span class="lineNum">     378 </span>            : inline Mat Mat::operator()( const Rect&amp; roi ) const
<span class="lineNum">     379 </span><span class="lineNoCov">          0 : { return Mat(*this, roi); }</span>
<span class="lineNum">     380 </span>            : 
<span class="lineNum">     381 </span>            : inline Mat Mat::operator()(const Range* ranges) const
<span class="lineNum">     382 </span>            : {
<span class="lineNum">     383 </span>            :     return Mat(*this, ranges);
<span class="lineNum">     384 </span>            : }
<span class="lineNum">     385 </span>            : 
<span class="lineNum">     386 </span>            : inline Mat::operator CvMat() const
<span class="lineNum">     387 </span>            : {
<span class="lineNum">     388 </span>            :     CV_DbgAssert(dims &lt;= 2);
<span class="lineNum">     389 </span>            :     CvMat m = cvMat(rows, dims == 1 ? 1 : cols, type(), data);
<span class="lineNum">     390 </span>            :     m.step = (int)step[0];
<span class="lineNum">     391 </span>            :     m.type = (m.type &amp; ~CONTINUOUS_FLAG) | (flags &amp; CONTINUOUS_FLAG);
<span class="lineNum">     392 </span>            :     return m;
<span class="lineNum">     393 </span>            : }
<span class="lineNum">     394 </span>            : 
<span class="lineNum">     395 </span>            : inline bool Mat::isContinuous() const { return (flags &amp; CONTINUOUS_FLAG) != 0; }
<span class="lineNum">     396 </span>            : inline bool Mat::isSubmatrix() const { return (flags &amp; SUBMATRIX_FLAG) != 0; }
<span class="lineNum">     397 </span>            : inline size_t Mat::elemSize() const { return dims &gt; 0 ? step.p[dims-1] : 0; }
<span class="lineNum">     398 </span>            : inline size_t Mat::elemSize1() const { return CV_ELEM_SIZE1(flags); }
<span class="lineNum">     399 </span>            : inline int Mat::type() const { return CV_MAT_TYPE(flags); }
<span class="lineNum">     400 </span><span class="lineNoCov">          0 : inline int Mat::depth() const { return CV_MAT_DEPTH(flags); }</span>
<span class="lineNum">     401 </span><span class="lineNoCov">          0 : inline int Mat::channels() const { return CV_MAT_CN(flags); }</span>
<span class="lineNum">     402 </span>            : inline size_t Mat::step1(int i) const { return step.p[i]/elemSize1(); }
<span class="lineNum">     403 </span>            : inline bool Mat::empty() const { return data == 0 || total() == 0; }
<span class="lineNum">     404 </span>            : inline size_t Mat::total() const
<span class="lineNum">     405 </span>            : {
<span class="lineNum">     406 </span>            :     if( dims &lt;= 2 )
<span class="lineNum">     407 </span>            :         return (size_t)rows*cols;
<span class="lineNum">     408 </span>            :     size_t p = 1;
<span class="lineNum">     409 </span>            :     for( int i = 0; i &lt; dims; i++ )
<span class="lineNum">     410 </span>            :         p *= size[i];
<span class="lineNum">     411 </span>            :     return p;
<span class="lineNum">     412 </span>            : }
<span class="lineNum">     413 </span>            : 
<span class="lineNum">     414 </span>            : inline uchar* Mat::ptr(int y)
<span class="lineNum">     415 </span>            : {
<span class="lineNum">     416 </span>            :     CV_DbgAssert( y == 0 || (data &amp;&amp; dims &gt;= 1 &amp;&amp; (unsigned)y &lt; (unsigned)size.p[0]) );
<span class="lineNum">     417 </span>            :     return data + step.p[0]*y;
<span class="lineNum">     418 </span>            : }
<span class="lineNum">     419 </span>            : 
<span class="lineNum">     420 </span>            : inline const uchar* Mat::ptr(int y) const
<span class="lineNum">     421 </span>            : {
<span class="lineNum">     422 </span>            :     CV_DbgAssert( y == 0 || (data &amp;&amp; dims &gt;= 1 &amp;&amp; (unsigned)y &lt; (unsigned)size.p[0]) );
<span class="lineNum">     423 </span>            :     return data + step.p[0]*y;
<span class="lineNum">     424 </span>            : }
<span class="lineNum">     425 </span>            : 
<span class="lineNum">     426 </span>            : template&lt;typename _Tp&gt; inline _Tp* Mat::ptr(int y)
<span class="lineNum">     427 </span>            : {
<span class="lineNum">     428 </span>            :     CV_DbgAssert( y == 0 || (data &amp;&amp; dims &gt;= 1 &amp;&amp; (unsigned)y &lt; (unsigned)size.p[0]) );
<span class="lineNum">     429 </span><span class="lineNoCov">          0 :     return (_Tp*)(data + step.p[0]*y);</span>
<span class="lineNum">     430 </span>            : }
<span class="lineNum">     431 </span>            : 
<span class="lineNum">     432 </span>            : template&lt;typename _Tp&gt; inline const _Tp* Mat::ptr(int y) const
<span class="lineNum">     433 </span>            : {
<span class="lineNum">     434 </span>            :     CV_DbgAssert( y == 0 || (data &amp;&amp; dims &gt;= 1 &amp;&amp; (unsigned)y &lt; (unsigned)size.p[0]) );
<span class="lineNum">     435 </span><span class="lineNoCov">          0 :     return (const _Tp*)(data + step.p[0]*y);</span>
<span class="lineNum">     436 </span>            : }
<span class="lineNum">     437 </span>            : 
<span class="lineNum">     438 </span>            : 
<span class="lineNum">     439 </span>            : inline uchar* Mat::ptr(int i0, int i1)
<span class="lineNum">     440 </span>            : {
<span class="lineNum">     441 </span>            :     CV_DbgAssert( dims &gt;= 2 &amp;&amp; data &amp;&amp;
<span class="lineNum">     442 </span>            :                   (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     443 </span>            :                   (unsigned)i1 &lt; (unsigned)size.p[1] );
<span class="lineNum">     444 </span>            :     return data + i0*step.p[0] + i1*step.p[1];
<span class="lineNum">     445 </span>            : }
<span class="lineNum">     446 </span>            : 
<span class="lineNum">     447 </span>            : inline const uchar* Mat::ptr(int i0, int i1) const
<span class="lineNum">     448 </span>            : {
<span class="lineNum">     449 </span>            :     CV_DbgAssert( dims &gt;= 2 &amp;&amp; data &amp;&amp;
<span class="lineNum">     450 </span>            :                  (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     451 </span>            :                  (unsigned)i1 &lt; (unsigned)size.p[1] );
<span class="lineNum">     452 </span>            :     return data + i0*step.p[0] + i1*step.p[1];
<span class="lineNum">     453 </span>            : }
<span class="lineNum">     454 </span>            : 
<span class="lineNum">     455 </span>            : template&lt;typename _Tp&gt; inline _Tp* Mat::ptr(int i0, int i1)
<span class="lineNum">     456 </span>            : {
<span class="lineNum">     457 </span>            :     CV_DbgAssert( dims &gt;= 2 &amp;&amp; data &amp;&amp;
<span class="lineNum">     458 </span>            :                   (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     459 </span>            :                   (unsigned)i1 &lt; (unsigned)size.p[1] );
<span class="lineNum">     460 </span>            :     return (_Tp*)(data + i0*step.p[0] + i1*step.p[1]);
<span class="lineNum">     461 </span>            : }
<span class="lineNum">     462 </span>            : 
<span class="lineNum">     463 </span>            : template&lt;typename _Tp&gt; inline const _Tp* Mat::ptr(int i0, int i1) const
<span class="lineNum">     464 </span>            : {
<span class="lineNum">     465 </span>            :     CV_DbgAssert( dims &gt;= 2 &amp;&amp; data &amp;&amp;
<span class="lineNum">     466 </span>            :                   (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     467 </span>            :                   (unsigned)i1 &lt; (unsigned)size.p[1] );
<span class="lineNum">     468 </span>            :     return (const _Tp*)(data + i0*step.p[0] + i1*step.p[1]);
<span class="lineNum">     469 </span>            : }
<span class="lineNum">     470 </span>            : 
<span class="lineNum">     471 </span>            : inline uchar* Mat::ptr(int i0, int i1, int i2)
<span class="lineNum">     472 </span>            : {
<span class="lineNum">     473 </span>            :     CV_DbgAssert( dims &gt;= 3 &amp;&amp; data &amp;&amp;
<span class="lineNum">     474 </span>            :                   (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     475 </span>            :                   (unsigned)i1 &lt; (unsigned)size.p[1] &amp;&amp;
<span class="lineNum">     476 </span>            :                   (unsigned)i2 &lt; (unsigned)size.p[2] );
<span class="lineNum">     477 </span>            :     return data + i0*step.p[0] + i1*step.p[1] + i2*step.p[2];
<span class="lineNum">     478 </span>            : }
<span class="lineNum">     479 </span>            : 
<span class="lineNum">     480 </span>            : inline const uchar* Mat::ptr(int i0, int i1, int i2) const
<span class="lineNum">     481 </span>            : {
<span class="lineNum">     482 </span>            :     CV_DbgAssert( dims &gt;= 3 &amp;&amp; data &amp;&amp;
<span class="lineNum">     483 </span>            :                   (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     484 </span>            :                   (unsigned)i1 &lt; (unsigned)size.p[1] &amp;&amp;
<span class="lineNum">     485 </span>            :                   (unsigned)i2 &lt; (unsigned)size.p[2] );
<span class="lineNum">     486 </span>            :     return data + i0*step.p[0] + i1*step.p[1] + i2*step.p[2];
<span class="lineNum">     487 </span>            : }
<span class="lineNum">     488 </span>            : 
<span class="lineNum">     489 </span>            : template&lt;typename _Tp&gt; inline _Tp* Mat::ptr(int i0, int i1, int i2)
<span class="lineNum">     490 </span>            : {
<span class="lineNum">     491 </span>            :     CV_DbgAssert( dims &gt;= 3 &amp;&amp; data &amp;&amp;
<span class="lineNum">     492 </span>            :                   (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     493 </span>            :                   (unsigned)i1 &lt; (unsigned)size.p[1] &amp;&amp;
<span class="lineNum">     494 </span>            :                   (unsigned)i2 &lt; (unsigned)size.p[2] );
<span class="lineNum">     495 </span>            :     return (_Tp*)(data + i0*step.p[0] + i1*step.p[1] + i2*step.p[2]);
<span class="lineNum">     496 </span>            : }
<span class="lineNum">     497 </span>            : 
<span class="lineNum">     498 </span>            : template&lt;typename _Tp&gt; inline const _Tp* Mat::ptr(int i0, int i1, int i2) const
<span class="lineNum">     499 </span>            : {
<span class="lineNum">     500 </span>            :     CV_DbgAssert( dims &gt;= 3 &amp;&amp; data &amp;&amp;
<span class="lineNum">     501 </span>            :                   (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     502 </span>            :                   (unsigned)i1 &lt; (unsigned)size.p[1] &amp;&amp;
<span class="lineNum">     503 </span>            :                   (unsigned)i2 &lt; (unsigned)size.p[2] );
<span class="lineNum">     504 </span>            :     return (const _Tp*)(data + i0*step.p[0] + i1*step.p[1] + i2*step.p[2]);
<span class="lineNum">     505 </span>            : }
<span class="lineNum">     506 </span>            : 
<span class="lineNum">     507 </span>            : inline uchar* Mat::ptr(const int* idx)
<span class="lineNum">     508 </span>            : {
<span class="lineNum">     509 </span>            :     int i, d = dims;
<span class="lineNum">     510 </span>            :     uchar* p = data;
<span class="lineNum">     511 </span>            :     CV_DbgAssert( d &gt;= 1 &amp;&amp; p );
<span class="lineNum">     512 </span>            :     for( i = 0; i &lt; d; i++ )
<span class="lineNum">     513 </span>            :     {
<span class="lineNum">     514 </span>            :         CV_DbgAssert( (unsigned)idx[i] &lt; (unsigned)size.p[i] );
<span class="lineNum">     515 </span>            :         p += idx[i]*step.p[i];
<span class="lineNum">     516 </span>            :     }
<span class="lineNum">     517 </span>            :     return p;
<span class="lineNum">     518 </span>            : }
<span class="lineNum">     519 </span>            : 
<span class="lineNum">     520 </span>            : inline const uchar* Mat::ptr(const int* idx) const
<span class="lineNum">     521 </span>            : {
<span class="lineNum">     522 </span>            :     int i, d = dims;
<span class="lineNum">     523 </span>            :     uchar* p = data;
<span class="lineNum">     524 </span>            :     CV_DbgAssert( d &gt;= 1 &amp;&amp; p );
<span class="lineNum">     525 </span>            :     for( i = 0; i &lt; d; i++ )
<span class="lineNum">     526 </span>            :     {
<span class="lineNum">     527 </span>            :         CV_DbgAssert( (unsigned)idx[i] &lt; (unsigned)size.p[i] );
<span class="lineNum">     528 </span>            :         p += idx[i]*step.p[i];
<span class="lineNum">     529 </span>            :     }
<span class="lineNum">     530 </span>            :     return p;
<span class="lineNum">     531 </span>            : }
<span class="lineNum">     532 </span>            : 
<span class="lineNum">     533 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; Mat::at(int i0, int i1)
<span class="lineNum">     534 </span>            : {
<span class="lineNum">     535 </span>            :     CV_DbgAssert( dims &lt;= 2 &amp;&amp; data &amp;&amp; (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     536 </span>            :         (unsigned)(i1*DataType&lt;_Tp&gt;::channels) &lt; (unsigned)(size.p[1]*channels()) &amp;&amp;
<span class="lineNum">     537 </span>            :         CV_ELEM_SIZE1(DataType&lt;_Tp&gt;::depth) == elemSize1());
<span class="lineNum">     538 </span>            :     return ((_Tp*)(data + step.p[0]*i0))[i1];
<span class="lineNum">     539 </span>            : }
<span class="lineNum">     540 </span>            : 
<span class="lineNum">     541 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp; Mat::at(int i0, int i1) const
<span class="lineNum">     542 </span>            : {
<span class="lineNum">     543 </span>            :     CV_DbgAssert( dims &lt;= 2 &amp;&amp; data &amp;&amp; (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     544 </span>            :         (unsigned)(i1*DataType&lt;_Tp&gt;::channels) &lt; (unsigned)(size.p[1]*channels()) &amp;&amp;
<span class="lineNum">     545 </span>            :         CV_ELEM_SIZE1(DataType&lt;_Tp&gt;::depth) == elemSize1());
<span class="lineNum">     546 </span>            :     return ((const _Tp*)(data + step.p[0]*i0))[i1];
<span class="lineNum">     547 </span>            : }
<span class="lineNum">     548 </span>            : 
<span class="lineNum">     549 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; Mat::at(Point pt)
<span class="lineNum">     550 </span>            : {
<span class="lineNum">     551 </span>            :     CV_DbgAssert( dims &lt;= 2 &amp;&amp; data &amp;&amp; (unsigned)pt.y &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     552 </span>            :         (unsigned)(pt.x*DataType&lt;_Tp&gt;::channels) &lt; (unsigned)(size.p[1]*channels()) &amp;&amp;
<span class="lineNum">     553 </span>            :         CV_ELEM_SIZE1(DataType&lt;_Tp&gt;::depth) == elemSize1());
<span class="lineNum">     554 </span>            :     return ((_Tp*)(data + step.p[0]*pt.y))[pt.x];
<span class="lineNum">     555 </span>            : }
<span class="lineNum">     556 </span>            : 
<span class="lineNum">     557 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp; Mat::at(Point pt) const
<span class="lineNum">     558 </span>            : {
<span class="lineNum">     559 </span>            :     CV_DbgAssert( dims &lt;= 2 &amp;&amp; data &amp;&amp; (unsigned)pt.y &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     560 </span>            :         (unsigned)(pt.x*DataType&lt;_Tp&gt;::channels) &lt; (unsigned)(size.p[1]*channels()) &amp;&amp;
<span class="lineNum">     561 </span>            :         CV_ELEM_SIZE1(DataType&lt;_Tp&gt;::depth) == elemSize1());
<span class="lineNum">     562 </span>            :     return ((const _Tp*)(data + step.p[0]*pt.y))[pt.x];
<span class="lineNum">     563 </span>            : }
<span class="lineNum">     564 </span>            : 
<span class="lineNum">     565 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; Mat::at(int i0)
<span class="lineNum">     566 </span>            : {
<span class="lineNum">     567 </span>            :     CV_DbgAssert( dims &lt;= 2 &amp;&amp; data &amp;&amp;
<span class="lineNum">     568 </span>            :                  (unsigned)i0 &lt; (unsigned)(size.p[0]*size.p[1]) &amp;&amp;
<span class="lineNum">     569 </span>            :                  elemSize() == CV_ELEM_SIZE(DataType&lt;_Tp&gt;::type) );
<span class="lineNum">     570 </span>            :     if( isContinuous() || size.p[0] == 1 )
<span class="lineNum">     571 </span>            :         return ((_Tp*)data)[i0];
<span class="lineNum">     572 </span>            :     if( size.p[1] == 1 )
<span class="lineNum">     573 </span>            :         return *(_Tp*)(data + step.p[0]*i0);
<span class="lineNum">     574 </span>            :     int i = i0/cols, j = i0 - i*cols;
<span class="lineNum">     575 </span>            :     return ((_Tp*)(data + step.p[0]*i))[j];
<span class="lineNum">     576 </span>            : }
<span class="lineNum">     577 </span>            : 
<span class="lineNum">     578 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp; Mat::at(int i0) const
<span class="lineNum">     579 </span>            : {
<span class="lineNum">     580 </span>            :     CV_DbgAssert( dims &lt;= 2 &amp;&amp; data &amp;&amp;
<span class="lineNum">     581 </span>            :                  (unsigned)i0 &lt; (unsigned)(size.p[0]*size.p[1]) &amp;&amp;
<span class="lineNum">     582 </span>            :                  elemSize() == CV_ELEM_SIZE(DataType&lt;_Tp&gt;::type) );
<span class="lineNum">     583 </span>            :     if( isContinuous() || size.p[0] == 1 )
<span class="lineNum">     584 </span>            :         return ((const _Tp*)data)[i0];
<span class="lineNum">     585 </span>            :     if( size.p[1] == 1 )
<span class="lineNum">     586 </span>            :         return *(const _Tp*)(data + step.p[0]*i0);
<span class="lineNum">     587 </span>            :     int i = i0/cols, j = i0 - i*cols;
<span class="lineNum">     588 </span>            :     return ((const _Tp*)(data + step.p[0]*i))[j];
<span class="lineNum">     589 </span>            : }
<span class="lineNum">     590 </span>            : 
<span class="lineNum">     591 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; Mat::at(int i0, int i1, int i2)
<span class="lineNum">     592 </span>            : {
<span class="lineNum">     593 </span>            :     CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType&lt;_Tp&gt;::type) );
<span class="lineNum">     594 </span>            :     return *(_Tp*)ptr(i0, i1, i2);
<span class="lineNum">     595 </span>            : }
<span class="lineNum">     596 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp; Mat::at(int i0, int i1, int i2) const
<span class="lineNum">     597 </span>            : {
<span class="lineNum">     598 </span>            :     CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType&lt;_Tp&gt;::type) );
<span class="lineNum">     599 </span>            :     return *(const _Tp*)ptr(i0, i1, i2);
<span class="lineNum">     600 </span>            : }
<span class="lineNum">     601 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; Mat::at(const int* idx)
<span class="lineNum">     602 </span>            : {
<span class="lineNum">     603 </span>            :     CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType&lt;_Tp&gt;::type) );
<span class="lineNum">     604 </span>            :     return *(_Tp*)ptr(idx);
<span class="lineNum">     605 </span>            : }
<span class="lineNum">     606 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp; Mat::at(const int* idx) const
<span class="lineNum">     607 </span>            : {
<span class="lineNum">     608 </span>            :     CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType&lt;_Tp&gt;::type) );
<span class="lineNum">     609 </span>            :     return *(const _Tp*)ptr(idx);
<span class="lineNum">     610 </span>            : }
<span class="lineNum">     611 </span>            : template&lt;typename _Tp, int n&gt; _Tp&amp; Mat::at(const Vec&lt;int, n&gt;&amp; idx)
<span class="lineNum">     612 </span>            : {
<span class="lineNum">     613 </span>            :     CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType&lt;_Tp&gt;::type) );
<span class="lineNum">     614 </span>            :     return *(_Tp*)ptr(idx.val);
<span class="lineNum">     615 </span>            : }
<span class="lineNum">     616 </span>            : template&lt;typename _Tp, int n&gt; inline const _Tp&amp; Mat::at(const Vec&lt;int, n&gt;&amp; idx) const
<span class="lineNum">     617 </span>            : {
<span class="lineNum">     618 </span>            :     CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType&lt;_Tp&gt;::type) );
<span class="lineNum">     619 </span>            :     return *(const _Tp*)ptr(idx.val);
<span class="lineNum">     620 </span>            : }
<span class="lineNum">     621 </span>            : 
<span class="lineNum">     622 </span>            : 
<span class="lineNum">     623 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt; Mat::begin() const
<span class="lineNum">     624 </span>            : {
<span class="lineNum">     625 </span>            :     CV_DbgAssert( elemSize() == sizeof(_Tp) );
<span class="lineNum">     626 </span>            :     return MatConstIterator_&lt;_Tp&gt;((const Mat_&lt;_Tp&gt;*)this);
<span class="lineNum">     627 </span>            : }
<span class="lineNum">     628 </span>            : 
<span class="lineNum">     629 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt; Mat::end() const
<span class="lineNum">     630 </span>            : {
<span class="lineNum">     631 </span>            :     CV_DbgAssert( elemSize() == sizeof(_Tp) );
<span class="lineNum">     632 </span>            :     MatConstIterator_&lt;_Tp&gt; it((const Mat_&lt;_Tp&gt;*)this);
<span class="lineNum">     633 </span>            :     it += total();
<span class="lineNum">     634 </span>            :     return it;
<span class="lineNum">     635 </span>            : }
<span class="lineNum">     636 </span>            : 
<span class="lineNum">     637 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt; Mat::begin()
<span class="lineNum">     638 </span>            : {
<span class="lineNum">     639 </span>            :     CV_DbgAssert( elemSize() == sizeof(_Tp) );
<span class="lineNum">     640 </span>            :     return MatIterator_&lt;_Tp&gt;((Mat_&lt;_Tp&gt;*)this);
<span class="lineNum">     641 </span>            : }
<span class="lineNum">     642 </span>            : 
<span class="lineNum">     643 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt; Mat::end()
<span class="lineNum">     644 </span>            : {
<span class="lineNum">     645 </span>            :     CV_DbgAssert( elemSize() == sizeof(_Tp) );
<span class="lineNum">     646 </span>            :     MatIterator_&lt;_Tp&gt; it((Mat_&lt;_Tp&gt;*)this);
<span class="lineNum">     647 </span>            :     it += total();
<span class="lineNum">     648 </span>            :     return it;
<span class="lineNum">     649 </span>            : }
<span class="lineNum">     650 </span>            : 
<span class="lineNum">     651 </span>            : template&lt;typename _Tp&gt; inline Mat::operator vector&lt;_Tp&gt;() const
<span class="lineNum">     652 </span>            : {
<span class="lineNum">     653 </span>            :     vector&lt;_Tp&gt; v;
<span class="lineNum">     654 </span>            :     copyTo(v);
<span class="lineNum">     655 </span>            :     return v;
<span class="lineNum">     656 </span>            : }
<span class="lineNum">     657 </span>            : 
<span class="lineNum">     658 </span>            : template&lt;typename _Tp, int n&gt; inline Mat::operator Vec&lt;_Tp, n&gt;() const
<span class="lineNum">     659 </span>            : {
<span class="lineNum">     660 </span>            :     CV_Assert( data &amp;&amp; dims &lt;= 2 &amp;&amp; (rows == 1 || cols == 1) &amp;&amp;
<span class="lineNum">     661 </span>            :                rows + cols - 1 == n &amp;&amp; channels() == 1 );
<span class="lineNum">     662 </span>            : 
<span class="lineNum">     663 </span>            :     if( isContinuous() &amp;&amp; type() == DataType&lt;_Tp&gt;::type )
<span class="lineNum">     664 </span>            :         return Vec&lt;_Tp, n&gt;((_Tp*)data);
<span class="lineNum">     665 </span>            :     Vec&lt;_Tp, n&gt; v; Mat tmp(rows, cols, DataType&lt;_Tp&gt;::type, v.val);
<span class="lineNum">     666 </span>            :     convertTo(tmp, tmp.type());
<span class="lineNum">     667 </span>            :     return v;
<span class="lineNum">     668 </span>            : }
<span class="lineNum">     669 </span>            : 
<span class="lineNum">     670 </span>            : template&lt;typename _Tp, int m, int n&gt; inline Mat::operator Matx&lt;_Tp, m, n&gt;() const
<span class="lineNum">     671 </span>            : {
<span class="lineNum">     672 </span>            :     CV_Assert( data &amp;&amp; dims &lt;= 2 &amp;&amp; rows == m &amp;&amp; cols == n &amp;&amp; channels() == 1 );
<span class="lineNum">     673 </span>            : 
<span class="lineNum">     674 </span>            :     if( isContinuous() &amp;&amp; type() == DataType&lt;_Tp&gt;::type )
<span class="lineNum">     675 </span>            :         return Matx&lt;_Tp, m, n&gt;((_Tp*)data);
<span class="lineNum">     676 </span>            :     Matx&lt;_Tp, m, n&gt; mtx; Mat tmp(rows, cols, DataType&lt;_Tp&gt;::type, mtx.val);
<span class="lineNum">     677 </span>            :     convertTo(tmp, tmp.type());
<span class="lineNum">     678 </span>            :     return mtx;
<span class="lineNum">     679 </span>            : }
<span class="lineNum">     680 </span>            : 
<span class="lineNum">     681 </span>            : 
<span class="lineNum">     682 </span>            : template&lt;typename _Tp&gt; inline void Mat::push_back(const _Tp&amp; elem)
<span class="lineNum">     683 </span>            : {
<span class="lineNum">     684 </span>            :     if( !data )
<span class="lineNum">     685 </span>            :     {
<span class="lineNum">     686 </span>            :         *this = Mat(1, 1, DataType&lt;_Tp&gt;::type, (void*)&amp;elem).clone();
<span class="lineNum">     687 </span>            :         return;
<span class="lineNum">     688 </span>            :     }
<span class="lineNum">     689 </span>            :     CV_Assert(DataType&lt;_Tp&gt;::type == type() &amp;&amp; cols == 1
<span class="lineNum">     690 </span>            :               /* &amp;&amp; dims == 2 (cols == 1 implies dims == 2) */);
<span class="lineNum">     691 </span>            :     uchar* tmp = dataend + step[0];
<span class="lineNum">     692 </span>            :     if( !isSubmatrix() &amp;&amp; isContinuous() &amp;&amp; tmp &lt;= datalimit )
<span class="lineNum">     693 </span>            :     {
<span class="lineNum">     694 </span>            :         *(_Tp*)(data + (size.p[0]++)*step.p[0]) = elem;
<span class="lineNum">     695 </span>            :         dataend = tmp;
<span class="lineNum">     696 </span>            :     }
<span class="lineNum">     697 </span>            :     else
<span class="lineNum">     698 </span>            :         push_back_(&amp;elem);
<span class="lineNum">     699 </span>            : }
<span class="lineNum">     700 </span>            : 
<span class="lineNum">     701 </span>            : template&lt;typename _Tp&gt; inline void Mat::push_back(const Mat_&lt;_Tp&gt;&amp; m)
<span class="lineNum">     702 </span>            : {
<span class="lineNum">     703 </span>            :     push_back((const Mat&amp;)m);
<span class="lineNum">     704 </span>            : }
<span class="lineNum">     705 </span>            : 
<span class="lineNum">     706 </span><span class="lineNoCov">          0 : inline Mat::MSize::MSize(int* _p) : p(_p) {}</span>
<span class="lineNum">     707 </span>            : inline Size Mat::MSize::operator()() const
<span class="lineNum">     708 </span>            : {
<span class="lineNum">     709 </span>            :     CV_DbgAssert(p[-1] &lt;= 2);
<span class="lineNum">     710 </span>            :     return Size(p[1], p[0]);
<span class="lineNum">     711 </span>            : }
<span class="lineNum">     712 </span>            : inline const int&amp; Mat::MSize::operator[](int i) const { return p[i]; }
<span class="lineNum">     713 </span>            : inline int&amp; Mat::MSize::operator[](int i) { return p[i]; }
<span class="lineNum">     714 </span>            : inline Mat::MSize::operator const int*() const { return p; }
<span class="lineNum">     715 </span>            : 
<span class="lineNum">     716 </span>            : inline bool Mat::MSize::operator == (const MSize&amp; sz) const
<span class="lineNum">     717 </span>            : {
<span class="lineNum">     718 </span>            :     int d = p[-1], dsz = sz.p[-1];
<span class="lineNum">     719 </span>            :     if( d != dsz )
<span class="lineNum">     720 </span>            :         return false;
<span class="lineNum">     721 </span>            :     if( d == 2 )
<span class="lineNum">     722 </span>            :         return p[0] == sz.p[0] &amp;&amp; p[1] == sz.p[1];
<span class="lineNum">     723 </span>            : 
<span class="lineNum">     724 </span>            :     for( int i = 0; i &lt; d; i++ )
<span class="lineNum">     725 </span>            :         if( p[i] != sz.p[i] )
<span class="lineNum">     726 </span>            :             return false;
<span class="lineNum">     727 </span>            :     return true;
<span class="lineNum">     728 </span>            : }
<span class="lineNum">     729 </span>            : 
<span class="lineNum">     730 </span>            : inline bool Mat::MSize::operator != (const MSize&amp; sz) const
<span class="lineNum">     731 </span>            : {
<span class="lineNum">     732 </span>            :     return !(*this == sz);
<span class="lineNum">     733 </span>            : }
<span class="lineNum">     734 </span>            : 
<span class="lineNum">     735 </span><span class="lineNoCov">          0 : inline Mat::MStep::MStep() { p = buf; p[0] = p[1] = 0; }</span>
<span class="lineNum">     736 </span>            : inline Mat::MStep::MStep(size_t s) { p = buf; p[0] = s; p[1] = 0; }
<span class="lineNum">     737 </span>            : inline const size_t&amp; Mat::MStep::operator[](int i) const { return p[i]; }
<span class="lineNum">     738 </span>            : inline size_t&amp; Mat::MStep::operator[](int i) { return p[i]; }
<span class="lineNum">     739 </span>            : inline Mat::MStep::operator size_t() const
<span class="lineNum">     740 </span>            : {
<span class="lineNum">     741 </span>            :     CV_DbgAssert( p == buf );
<span class="lineNum">     742 </span>            :     return buf[0];
<span class="lineNum">     743 </span>            : }
<span class="lineNum">     744 </span>            : inline Mat::MStep&amp; Mat::MStep::operator = (size_t s)
<span class="lineNum">     745 </span>            : {
<span class="lineNum">     746 </span>            :     CV_DbgAssert( p == buf );
<span class="lineNum">     747 </span>            :     buf[0] = s;
<span class="lineNum">     748 </span>            :     return *this;
<span class="lineNum">     749 </span>            : }
<span class="lineNum">     750 </span>            : 
<span class="lineNum">     751 </span>            : static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMode=0)
<span class="lineNum">     752 </span>            : {
<span class="lineNum">     753 </span>            :     return cvarrToMat(arr, copyData, true, coiMode);
<span class="lineNum">     754 </span>            : }
<span class="lineNum">     755 </span>            : 
<span class="lineNum">     756 </span>            : ///////////////////////////////////////////// SVD //////////////////////////////////////////////////////
<span class="lineNum">     757 </span>            : 
<span class="lineNum">     758 </span>            : inline SVD::SVD() {}
<span class="lineNum">     759 </span>            : inline SVD::SVD( InputArray m, int flags ) { operator ()(m, flags); }
<span class="lineNum">     760 </span>            : inline void SVD::solveZ( InputArray m, OutputArray _dst )
<span class="lineNum">     761 </span>            : {
<span class="lineNum">     762 </span>            :     Mat mtx = m.getMat();
<span class="lineNum">     763 </span>            :     SVD svd(mtx, (mtx.rows &gt;= mtx.cols ? 0 : SVD::FULL_UV));
<span class="lineNum">     764 </span>            :     _dst.create(svd.vt.cols, 1, svd.vt.type());
<span class="lineNum">     765 </span>            :     Mat dst = _dst.getMat();
<span class="lineNum">     766 </span>            :     svd.vt.row(svd.vt.rows-1).reshape(1,svd.vt.cols).copyTo(dst);
<span class="lineNum">     767 </span>            : }
<span class="lineNum">     768 </span>            : 
<span class="lineNum">     769 </span>            : template&lt;typename _Tp, int m, int n, int nm&gt; inline void
<span class="lineNum">     770 </span>            :     SVD::compute( const Matx&lt;_Tp, m, n&gt;&amp; a, Matx&lt;_Tp, nm, 1&gt;&amp; w, Matx&lt;_Tp, m, nm&gt;&amp; u, Matx&lt;_Tp, n, nm&gt;&amp; vt )
<span class="lineNum">     771 </span>            : {
<span class="lineNum">     772 </span>            :     assert( nm == MIN(m, n));
<span class="lineNum">     773 </span>            :     Mat _a(a, false), _u(u, false), _w(w, false), _vt(vt, false);
<span class="lineNum">     774 </span>            :     SVD::compute(_a, _w, _u, _vt);
<span class="lineNum">     775 </span>            :     CV_Assert(_w.data == (uchar*)&amp;w.val[0] &amp;&amp; _u.data == (uchar*)&amp;u.val[0] &amp;&amp; _vt.data == (uchar*)&amp;vt.val[0]);
<span class="lineNum">     776 </span>            : }
<span class="lineNum">     777 </span>            : 
<span class="lineNum">     778 </span>            : template&lt;typename _Tp, int m, int n, int nm&gt; inline void
<span class="lineNum">     779 </span>            : SVD::compute( const Matx&lt;_Tp, m, n&gt;&amp; a, Matx&lt;_Tp, nm, 1&gt;&amp; w )
<span class="lineNum">     780 </span>            : {
<span class="lineNum">     781 </span>            :     assert( nm == MIN(m, n));
<span class="lineNum">     782 </span>            :     Mat _a(a, false), _w(w, false);
<span class="lineNum">     783 </span>            :     SVD::compute(_a, _w);
<span class="lineNum">     784 </span>            :     CV_Assert(_w.data == (uchar*)&amp;w.val[0]);
<span class="lineNum">     785 </span>            : }
<span class="lineNum">     786 </span>            : 
<span class="lineNum">     787 </span>            : template&lt;typename _Tp, int m, int n, int nm, int nb&gt; inline void
<span class="lineNum">     788 </span>            : SVD::backSubst( const Matx&lt;_Tp, nm, 1&gt;&amp; w, const Matx&lt;_Tp, m, nm&gt;&amp; u,
<span class="lineNum">     789 </span>            :                 const Matx&lt;_Tp, n, nm&gt;&amp; vt, const Matx&lt;_Tp, m, nb&gt;&amp; rhs,
<span class="lineNum">     790 </span>            :                 Matx&lt;_Tp, n, nb&gt;&amp; dst )
<span class="lineNum">     791 </span>            : {
<span class="lineNum">     792 </span>            :     assert( nm == MIN(m, n));
<span class="lineNum">     793 </span>            :     Mat _u(u, false), _w(w, false), _vt(vt, false), _rhs(rhs, false), _dst(dst, false);
<span class="lineNum">     794 </span>            :     SVD::backSubst(_w, _u, _vt, _rhs, _dst);
<span class="lineNum">     795 </span>            :     CV_Assert(_dst.data == (uchar*)&amp;dst.val[0]);
<span class="lineNum">     796 </span>            : }
<span class="lineNum">     797 </span>            : 
<span class="lineNum">     798 </span>            : ///////////////////////////////// Mat_&lt;_Tp&gt; ////////////////////////////////////
<span class="lineNum">     799 </span>            : 
<span class="lineNum">     800 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_()
<span class="lineNum">     801 </span>            :     : Mat() { flags = (flags &amp; ~CV_MAT_TYPE_MASK) | DataType&lt;_Tp&gt;::type; }
<span class="lineNum">     802 </span>            : 
<span class="lineNum">     803 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(int _rows, int _cols)
<span class="lineNum">     804 </span>            :     : Mat(_rows, _cols, DataType&lt;_Tp&gt;::type) {}
<span class="lineNum">     805 </span>            : 
<span class="lineNum">     806 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(int _rows, int _cols, const _Tp&amp; value)
<span class="lineNum">     807 </span>            :     : Mat(_rows, _cols, DataType&lt;_Tp&gt;::type) { *this = value; }
<span class="lineNum">     808 </span>            : 
<span class="lineNum">     809 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(Size _sz)
<span class="lineNum">     810 </span>            :     : Mat(_sz.height, _sz.width, DataType&lt;_Tp&gt;::type) {}
<span class="lineNum">     811 </span>            : 
<span class="lineNum">     812 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(Size _sz, const _Tp&amp; value)
<span class="lineNum">     813 </span>            :     : Mat(_sz.height, _sz.width, DataType&lt;_Tp&gt;::type) { *this = value; }
<span class="lineNum">     814 </span>            : 
<span class="lineNum">     815 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(int _dims, const int* _sz)
<span class="lineNum">     816 </span>            :     : Mat(_dims, _sz, DataType&lt;_Tp&gt;::type) {}
<span class="lineNum">     817 </span>            : 
<span class="lineNum">     818 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(int _dims, const int* _sz, const _Tp&amp; _s)
<span class="lineNum">     819 </span>            :     : Mat(_dims, _sz, DataType&lt;_Tp&gt;::type, Scalar(_s)) {}
<span class="lineNum">     820 </span>            : 
<span class="lineNum">     821 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(const Mat_&lt;_Tp&gt;&amp; m, const Range* ranges)
<span class="lineNum">     822 </span>            :     : Mat(m, ranges) {}
<span class="lineNum">     823 </span>            : 
<span class="lineNum">     824 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(const Mat&amp; m)
<span class="lineNum">     825 </span>            :     : Mat() { flags = (flags &amp; ~CV_MAT_TYPE_MASK) | DataType&lt;_Tp&gt;::type; *this = m; }
<span class="lineNum">     826 </span>            : 
<span class="lineNum">     827 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(const Mat_&amp; m)
<span class="lineNum">     828 </span>            :     : Mat(m) {}
<span class="lineNum">     829 </span>            : 
<span class="lineNum">     830 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(int _rows, int _cols, _Tp* _data, size_t steps)
<span class="lineNum">     831 </span>            :     : Mat(_rows, _cols, DataType&lt;_Tp&gt;::type, _data, steps) {}
<span class="lineNum">     832 </span>            : 
<span class="lineNum">     833 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(const Mat_&amp; m, const Range&amp; _rowRange, const Range&amp; _colRange)
<span class="lineNum">     834 </span>            :     : Mat(m, _rowRange, _colRange) {}
<span class="lineNum">     835 </span>            : 
<span class="lineNum">     836 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(const Mat_&amp; m, const Rect&amp; roi)
<span class="lineNum">     837 </span>            :     : Mat(m, roi) {}
<span class="lineNum">     838 </span>            : 
<span class="lineNum">     839 </span>            : template&lt;typename _Tp&gt; template&lt;int n&gt; inline
<span class="lineNum">     840 </span>            :     Mat_&lt;_Tp&gt;::Mat_(const Vec&lt;typename DataType&lt;_Tp&gt;::channel_type, n&gt;&amp; vec, bool copyData)
<span class="lineNum">     841 </span>            :     : Mat(n/DataType&lt;_Tp&gt;::channels, 1, DataType&lt;_Tp&gt;::type, (void*)&amp;vec)
<span class="lineNum">     842 </span>            : {
<span class="lineNum">     843 </span>            :     CV_Assert(n%DataType&lt;_Tp&gt;::channels == 0);
<span class="lineNum">     844 </span>            :     if( copyData )
<span class="lineNum">     845 </span>            :         *this = clone();
<span class="lineNum">     846 </span>            : }
<span class="lineNum">     847 </span>            : 
<span class="lineNum">     848 </span>            : template&lt;typename _Tp&gt; template&lt;int m, int n&gt; inline
<span class="lineNum">     849 </span>            :     Mat_&lt;_Tp&gt;::Mat_(const Matx&lt;typename DataType&lt;_Tp&gt;::channel_type,m,n&gt;&amp; M, bool copyData)
<span class="lineNum">     850 </span>            :     : Mat(m, n/DataType&lt;_Tp&gt;::channels, DataType&lt;_Tp&gt;::type, (void*)&amp;M)
<span class="lineNum">     851 </span>            : {
<span class="lineNum">     852 </span>            :     CV_Assert(n % DataType&lt;_Tp&gt;::channels == 0);
<span class="lineNum">     853 </span>            :     if( copyData )
<span class="lineNum">     854 </span>            :         *this = clone();
<span class="lineNum">     855 </span>            : }
<span class="lineNum">     856 </span>            : 
<span class="lineNum">     857 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(const Point_&lt;typename DataType&lt;_Tp&gt;::channel_type&gt;&amp; pt, bool copyData)
<span class="lineNum">     858 </span>            :     : Mat(2/DataType&lt;_Tp&gt;::channels, 1, DataType&lt;_Tp&gt;::type, (void*)&amp;pt)
<span class="lineNum">     859 </span>            : {
<span class="lineNum">     860 </span>            :     CV_Assert(2 % DataType&lt;_Tp&gt;::channels == 0);
<span class="lineNum">     861 </span>            :     if( copyData )
<span class="lineNum">     862 </span>            :         *this = clone();
<span class="lineNum">     863 </span>            : }
<span class="lineNum">     864 </span>            : 
<span class="lineNum">     865 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(const Point3_&lt;typename DataType&lt;_Tp&gt;::channel_type&gt;&amp; pt, bool copyData)
<span class="lineNum">     866 </span>            :     : Mat(3/DataType&lt;_Tp&gt;::channels, 1, DataType&lt;_Tp&gt;::type, (void*)&amp;pt)
<span class="lineNum">     867 </span>            : {
<span class="lineNum">     868 </span>            :     CV_Assert(3 % DataType&lt;_Tp&gt;::channels == 0);
<span class="lineNum">     869 </span>            :     if( copyData )
<span class="lineNum">     870 </span>            :         *this = clone();
<span class="lineNum">     871 </span>            : }
<span class="lineNum">     872 </span>            : 
<span class="lineNum">     873 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(const MatCommaInitializer_&lt;_Tp&gt;&amp; commaInitializer)
<span class="lineNum">     874 </span>            :     : Mat(commaInitializer) {}
<span class="lineNum">     875 </span>            : 
<span class="lineNum">     876 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(const vector&lt;_Tp&gt;&amp; vec, bool copyData)
<span class="lineNum">     877 </span>            :     : Mat(vec, copyData) {}
<span class="lineNum">     878 </span>            : 
<span class="lineNum">     879 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;&amp; Mat_&lt;_Tp&gt;::operator = (const Mat&amp; m)
<span class="lineNum">     880 </span>            : {
<span class="lineNum">     881 </span>            :     if( DataType&lt;_Tp&gt;::type == m.type() )
<span class="lineNum">     882 </span>            :     {
<span class="lineNum">     883 </span>            :         Mat::operator = (m);
<span class="lineNum">     884 </span>            :         return *this;
<span class="lineNum">     885 </span>            :     }
<span class="lineNum">     886 </span>            :     if( DataType&lt;_Tp&gt;::depth == m.depth() )
<span class="lineNum">     887 </span>            :     {
<span class="lineNum">     888 </span>            :         return (*this = m.reshape(DataType&lt;_Tp&gt;::channels, m.dims, 0));
<span class="lineNum">     889 </span>            :     }
<span class="lineNum">     890 </span>            :     CV_DbgAssert(DataType&lt;_Tp&gt;::channels == m.channels());
<span class="lineNum">     891 </span>            :     m.convertTo(*this, type());
<span class="lineNum">     892 </span>            :     return *this;
<span class="lineNum">     893 </span>            : }
<span class="lineNum">     894 </span>            : 
<span class="lineNum">     895 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;&amp; Mat_&lt;_Tp&gt;::operator = (const Mat_&amp; m)
<span class="lineNum">     896 </span>            : {
<span class="lineNum">     897 </span>            :     Mat::operator=(m);
<span class="lineNum">     898 </span>            :     return *this;
<span class="lineNum">     899 </span>            : }
<span class="lineNum">     900 </span>            : 
<span class="lineNum">     901 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;&amp; Mat_&lt;_Tp&gt;::operator = (const _Tp&amp; s)
<span class="lineNum">     902 </span>            : {
<span class="lineNum">     903 </span>            :     typedef typename DataType&lt;_Tp&gt;::vec_type VT;
<span class="lineNum">     904 </span>            :     Mat::operator=(Scalar((const VT&amp;)s));
<span class="lineNum">     905 </span>            :     return *this;
<span class="lineNum">     906 </span>            : }
<span class="lineNum">     907 </span>            : 
<span class="lineNum">     908 </span>            : template&lt;typename _Tp&gt; inline void Mat_&lt;_Tp&gt;::create(int _rows, int _cols)
<span class="lineNum">     909 </span>            : {
<span class="lineNum">     910 </span>            :     Mat::create(_rows, _cols, DataType&lt;_Tp&gt;::type);
<span class="lineNum">     911 </span>            : }
<span class="lineNum">     912 </span>            : 
<span class="lineNum">     913 </span>            : template&lt;typename _Tp&gt; inline void Mat_&lt;_Tp&gt;::create(Size _sz)
<span class="lineNum">     914 </span>            : {
<span class="lineNum">     915 </span>            :     Mat::create(_sz, DataType&lt;_Tp&gt;::type);
<span class="lineNum">     916 </span>            : }
<span class="lineNum">     917 </span>            : 
<span class="lineNum">     918 </span>            : template&lt;typename _Tp&gt; inline void Mat_&lt;_Tp&gt;::create(int _dims, const int* _sz)
<span class="lineNum">     919 </span>            : {
<span class="lineNum">     920 </span>            :     Mat::create(_dims, _sz, DataType&lt;_Tp&gt;::type);
<span class="lineNum">     921 </span>            : }
<span class="lineNum">     922 </span>            : 
<span class="lineNum">     923 </span>            : 
<span class="lineNum">     924 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt; Mat_&lt;_Tp&gt;::cross(const Mat_&amp; m) const
<span class="lineNum">     925 </span>            : { return Mat_&lt;_Tp&gt;(Mat::cross(m)); }
<span class="lineNum">     926 </span>            : 
<span class="lineNum">     927 </span>            : template&lt;typename _Tp&gt; template&lt;typename T2&gt; inline Mat_&lt;_Tp&gt;::operator Mat_&lt;T2&gt;() const
<span class="lineNum">     928 </span>            : { return Mat_&lt;T2&gt;(*this); }
<span class="lineNum">     929 </span>            : 
<span class="lineNum">     930 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt; Mat_&lt;_Tp&gt;::row(int y) const
<span class="lineNum">     931 </span>            : { return Mat_(*this, Range(y, y+1), Range::all()); }
<span class="lineNum">     932 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt; Mat_&lt;_Tp&gt;::col(int x) const
<span class="lineNum">     933 </span>            : { return Mat_(*this, Range::all(), Range(x, x+1)); }
<span class="lineNum">     934 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt; Mat_&lt;_Tp&gt;::diag(int d) const
<span class="lineNum">     935 </span>            : { return Mat_(Mat::diag(d)); }
<span class="lineNum">     936 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt; Mat_&lt;_Tp&gt;::clone() const
<span class="lineNum">     937 </span>            : { return Mat_(Mat::clone()); }
<span class="lineNum">     938 </span>            : 
<span class="lineNum">     939 </span>            : template&lt;typename _Tp&gt; inline size_t Mat_&lt;_Tp&gt;::elemSize() const
<span class="lineNum">     940 </span>            : {
<span class="lineNum">     941 </span>            :     CV_DbgAssert( Mat::elemSize() == sizeof(_Tp) );
<span class="lineNum">     942 </span>            :     return sizeof(_Tp);
<span class="lineNum">     943 </span>            : }
<span class="lineNum">     944 </span>            : 
<span class="lineNum">     945 </span>            : template&lt;typename _Tp&gt; inline size_t Mat_&lt;_Tp&gt;::elemSize1() const
<span class="lineNum">     946 </span>            : {
<span class="lineNum">     947 </span>            :     CV_DbgAssert( Mat::elemSize1() == sizeof(_Tp)/DataType&lt;_Tp&gt;::channels );
<span class="lineNum">     948 </span>            :     return sizeof(_Tp)/DataType&lt;_Tp&gt;::channels;
<span class="lineNum">     949 </span>            : }
<span class="lineNum">     950 </span>            : template&lt;typename _Tp&gt; inline int Mat_&lt;_Tp&gt;::type() const
<span class="lineNum">     951 </span>            : {
<span class="lineNum">     952 </span>            :     CV_DbgAssert( Mat::type() == DataType&lt;_Tp&gt;::type );
<span class="lineNum">     953 </span>            :     return DataType&lt;_Tp&gt;::type;
<span class="lineNum">     954 </span>            : }
<span class="lineNum">     955 </span>            : template&lt;typename _Tp&gt; inline int Mat_&lt;_Tp&gt;::depth() const
<span class="lineNum">     956 </span>            : {
<span class="lineNum">     957 </span>            :     CV_DbgAssert( Mat::depth() == DataType&lt;_Tp&gt;::depth );
<span class="lineNum">     958 </span>            :     return DataType&lt;_Tp&gt;::depth;
<span class="lineNum">     959 </span>            : }
<span class="lineNum">     960 </span>            : template&lt;typename _Tp&gt; inline int Mat_&lt;_Tp&gt;::channels() const
<span class="lineNum">     961 </span>            : {
<span class="lineNum">     962 </span>            :     CV_DbgAssert( Mat::channels() == DataType&lt;_Tp&gt;::channels );
<span class="lineNum">     963 </span>            :     return DataType&lt;_Tp&gt;::channels;
<span class="lineNum">     964 </span>            : }
<span class="lineNum">     965 </span>            : template&lt;typename _Tp&gt; inline size_t Mat_&lt;_Tp&gt;::stepT(int i) const { return step.p[i]/elemSize(); }
<span class="lineNum">     966 </span>            : template&lt;typename _Tp&gt; inline size_t Mat_&lt;_Tp&gt;::step1(int i) const { return step.p[i]/elemSize1(); }
<span class="lineNum">     967 </span>            : 
<span class="lineNum">     968 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;&amp; Mat_&lt;_Tp&gt;::adjustROI( int dtop, int dbottom, int dleft, int dright )
<span class="lineNum">     969 </span>            : { return (Mat_&lt;_Tp&gt;&amp;)(Mat::adjustROI(dtop, dbottom, dleft, dright));  }
<span class="lineNum">     970 </span>            : 
<span class="lineNum">     971 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt; Mat_&lt;_Tp&gt;::operator()( const Range&amp; _rowRange, const Range&amp; _colRange ) const
<span class="lineNum">     972 </span>            : { return Mat_&lt;_Tp&gt;(*this, _rowRange, _colRange); }
<span class="lineNum">     973 </span>            : 
<span class="lineNum">     974 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt; Mat_&lt;_Tp&gt;::operator()( const Rect&amp; roi ) const
<span class="lineNum">     975 </span>            : { return Mat_&lt;_Tp&gt;(*this, roi); }
<span class="lineNum">     976 </span>            : 
<span class="lineNum">     977 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt; Mat_&lt;_Tp&gt;::operator()( const Range* ranges ) const
<span class="lineNum">     978 </span>            : { return Mat_&lt;_Tp&gt;(*this, ranges); }
<span class="lineNum">     979 </span>            : 
<span class="lineNum">     980 </span>            : template&lt;typename _Tp&gt; inline _Tp* Mat_&lt;_Tp&gt;::operator [](int y)
<span class="lineNum">     981 </span>            : { return (_Tp*)ptr(y); }
<span class="lineNum">     982 </span>            : template&lt;typename _Tp&gt; inline const _Tp* Mat_&lt;_Tp&gt;::operator [](int y) const
<span class="lineNum">     983 </span>            : { return (const _Tp*)ptr(y); }
<span class="lineNum">     984 </span>            : 
<span class="lineNum">     985 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; Mat_&lt;_Tp&gt;::operator ()(int i0, int i1)
<span class="lineNum">     986 </span>            : {
<span class="lineNum">     987 </span>            :     CV_DbgAssert( dims &lt;= 2 &amp;&amp; data &amp;&amp;
<span class="lineNum">     988 </span>            :                   (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     989 </span>            :                   (unsigned)i1 &lt; (unsigned)size.p[1] &amp;&amp;
<span class="lineNum">     990 </span>            :                   type() == DataType&lt;_Tp&gt;::type );
<span class="lineNum">     991 </span>            :     return ((_Tp*)(data + step.p[0]*i0))[i1];
<span class="lineNum">     992 </span>            : }
<span class="lineNum">     993 </span>            : 
<span class="lineNum">     994 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp; Mat_&lt;_Tp&gt;::operator ()(int i0, int i1) const
<span class="lineNum">     995 </span>            : {
<span class="lineNum">     996 </span>            :     CV_DbgAssert( dims &lt;= 2 &amp;&amp; data &amp;&amp;
<span class="lineNum">     997 </span>            :                   (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">     998 </span>            :                   (unsigned)i1 &lt; (unsigned)size.p[1] &amp;&amp;
<span class="lineNum">     999 </span>            :                   type() == DataType&lt;_Tp&gt;::type );
<span class="lineNum">    1000 </span>            :     return ((const _Tp*)(data + step.p[0]*i0))[i1];
<span class="lineNum">    1001 </span>            : }
<span class="lineNum">    1002 </span>            : 
<span class="lineNum">    1003 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; Mat_&lt;_Tp&gt;::operator ()(Point pt)
<span class="lineNum">    1004 </span>            : {
<span class="lineNum">    1005 </span>            :     CV_DbgAssert( dims &lt;= 2 &amp;&amp; data &amp;&amp;
<span class="lineNum">    1006 </span>            :                   (unsigned)pt.y &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">    1007 </span>            :                   (unsigned)pt.x &lt; (unsigned)size.p[1] &amp;&amp;
<span class="lineNum">    1008 </span>            :                   type() == DataType&lt;_Tp&gt;::type );
<span class="lineNum">    1009 </span>            :     return ((_Tp*)(data + step.p[0]*pt.y))[pt.x];
<span class="lineNum">    1010 </span>            : }
<span class="lineNum">    1011 </span>            : 
<span class="lineNum">    1012 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp; Mat_&lt;_Tp&gt;::operator ()(Point pt) const
<span class="lineNum">    1013 </span>            : {
<span class="lineNum">    1014 </span>            :     CV_DbgAssert( dims &lt;= 2 &amp;&amp; data &amp;&amp;
<span class="lineNum">    1015 </span>            :                   (unsigned)pt.y &lt; (unsigned)size.p[0] &amp;&amp;
<span class="lineNum">    1016 </span>            :                   (unsigned)pt.x &lt; (unsigned)size.p[1] &amp;&amp;
<span class="lineNum">    1017 </span>            :                  type() == DataType&lt;_Tp&gt;::type );
<span class="lineNum">    1018 </span>            :     return ((const _Tp*)(data + step.p[0]*pt.y))[pt.x];
<span class="lineNum">    1019 </span>            : }
<span class="lineNum">    1020 </span>            : 
<span class="lineNum">    1021 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; Mat_&lt;_Tp&gt;::operator ()(const int* idx)
<span class="lineNum">    1022 </span>            : {
<span class="lineNum">    1023 </span>            :     return Mat::at&lt;_Tp&gt;(idx);
<span class="lineNum">    1024 </span>            : }
<span class="lineNum">    1025 </span>            : 
<span class="lineNum">    1026 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp; Mat_&lt;_Tp&gt;::operator ()(const int* idx) const
<span class="lineNum">    1027 </span>            : {
<span class="lineNum">    1028 </span>            :     return Mat::at&lt;_Tp&gt;(idx);
<span class="lineNum">    1029 </span>            : }
<span class="lineNum">    1030 </span>            : 
<span class="lineNum">    1031 </span>            : template&lt;typename _Tp&gt; template&lt;int n&gt; inline _Tp&amp; Mat_&lt;_Tp&gt;::operator ()(const Vec&lt;int, n&gt;&amp; idx)
<span class="lineNum">    1032 </span>            : {
<span class="lineNum">    1033 </span>            :     return Mat::at&lt;_Tp&gt;(idx);
<span class="lineNum">    1034 </span>            : }
<span class="lineNum">    1035 </span>            : 
<span class="lineNum">    1036 </span>            : template&lt;typename _Tp&gt; template&lt;int n&gt; inline const _Tp&amp; Mat_&lt;_Tp&gt;::operator ()(const Vec&lt;int, n&gt;&amp; idx) const
<span class="lineNum">    1037 </span>            : {
<span class="lineNum">    1038 </span>            :     return Mat::at&lt;_Tp&gt;(idx);
<span class="lineNum">    1039 </span>            : }
<span class="lineNum">    1040 </span>            : 
<span class="lineNum">    1041 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; Mat_&lt;_Tp&gt;::operator ()(int i0)
<span class="lineNum">    1042 </span>            : {
<span class="lineNum">    1043 </span>            :     return this-&gt;at&lt;_Tp&gt;(i0);
<span class="lineNum">    1044 </span>            : }
<span class="lineNum">    1045 </span>            : 
<span class="lineNum">    1046 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp; Mat_&lt;_Tp&gt;::operator ()(int i0) const
<span class="lineNum">    1047 </span>            : {
<span class="lineNum">    1048 </span>            :     return this-&gt;at&lt;_Tp&gt;(i0);
<span class="lineNum">    1049 </span>            : }
<span class="lineNum">    1050 </span>            : 
<span class="lineNum">    1051 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; Mat_&lt;_Tp&gt;::operator ()(int i0, int i1, int i2)
<span class="lineNum">    1052 </span>            : {
<span class="lineNum">    1053 </span>            :     return this-&gt;at&lt;_Tp&gt;(i0, i1, i2);
<span class="lineNum">    1054 </span>            : }
<span class="lineNum">    1055 </span>            : 
<span class="lineNum">    1056 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp; Mat_&lt;_Tp&gt;::operator ()(int i0, int i1, int i2) const
<span class="lineNum">    1057 </span>            : {
<span class="lineNum">    1058 </span>            :     return this-&gt;at&lt;_Tp&gt;(i0, i1, i2);
<span class="lineNum">    1059 </span>            : }
<span class="lineNum">    1060 </span>            : 
<span class="lineNum">    1061 </span>            : 
<span class="lineNum">    1062 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::operator vector&lt;_Tp&gt;() const
<span class="lineNum">    1063 </span>            : {
<span class="lineNum">    1064 </span>            :     vector&lt;_Tp&gt; v;
<span class="lineNum">    1065 </span>            :     copyTo(v);
<span class="lineNum">    1066 </span>            :     return v;
<span class="lineNum">    1067 </span>            : }
<span class="lineNum">    1068 </span>            : 
<span class="lineNum">    1069 </span>            : template&lt;typename _Tp&gt; template&lt;int n&gt; inline Mat_&lt;_Tp&gt;::operator Vec&lt;typename DataType&lt;_Tp&gt;::channel_type, n&gt;() const
<span class="lineNum">    1070 </span>            : {
<span class="lineNum">    1071 </span>            :     CV_Assert(n % DataType&lt;_Tp&gt;::channels == 0);
<span class="lineNum">    1072 </span>            :     return this-&gt;Mat::operator Vec&lt;typename DataType&lt;_Tp&gt;::channel_type, n&gt;();
<span class="lineNum">    1073 </span>            : }
<span class="lineNum">    1074 </span>            : 
<span class="lineNum">    1075 </span>            : template&lt;typename _Tp&gt; template&lt;int m, int n&gt; inline Mat_&lt;_Tp&gt;::operator Matx&lt;typename DataType&lt;_Tp&gt;::channel_type, m, n&gt;() const
<span class="lineNum">    1076 </span>            : {
<span class="lineNum">    1077 </span>            :     CV_Assert(n % DataType&lt;_Tp&gt;::channels == 0);
<span class="lineNum">    1078 </span>            : 
<span class="lineNum">    1079 </span>            :     Matx&lt;typename DataType&lt;_Tp&gt;::channel_type, m, n&gt; res = this-&gt;Mat::operator Matx&lt;typename DataType&lt;_Tp&gt;::channel_type, m, n&gt;();
<span class="lineNum">    1080 </span>            :     return res;
<span class="lineNum">    1081 </span>            : }
<span class="lineNum">    1082 </span>            : 
<span class="lineNum">    1083 </span>            : template&lt;typename T1, typename T2, typename Op&gt; inline void
<span class="lineNum">    1084 </span>            : process( const Mat_&lt;T1&gt;&amp; m1, Mat_&lt;T2&gt;&amp; m2, Op op )
<span class="lineNum">    1085 </span>            : {
<span class="lineNum">    1086 </span>            :     int y, x, rows = m1.rows, cols = m1.cols;
<span class="lineNum">    1087 </span>            : 
<span class="lineNum">    1088 </span>            :     CV_DbgAssert( m1.size() == m2.size() );
<span class="lineNum">    1089 </span>            : 
<span class="lineNum">    1090 </span>            :     for( y = 0; y &lt; rows; y++ )
<span class="lineNum">    1091 </span>            :     {
<span class="lineNum">    1092 </span>            :         const T1* src = m1[y];
<span class="lineNum">    1093 </span>            :         T2* dst = m2[y];
<span class="lineNum">    1094 </span>            : 
<span class="lineNum">    1095 </span>            :         for( x = 0; x &lt; cols; x++ )
<span class="lineNum">    1096 </span>            :             dst[x] = op(src[x]);
<span class="lineNum">    1097 </span>            :     }
<span class="lineNum">    1098 </span>            : }
<span class="lineNum">    1099 </span>            : 
<span class="lineNum">    1100 </span>            : template&lt;typename T1, typename T2, typename T3, typename Op&gt; inline void
<span class="lineNum">    1101 </span>            : process( const Mat_&lt;T1&gt;&amp; m1, const Mat_&lt;T2&gt;&amp; m2, Mat_&lt;T3&gt;&amp; m3, Op op )
<span class="lineNum">    1102 </span>            : {
<span class="lineNum">    1103 </span>            :     int y, x, rows = m1.rows, cols = m1.cols;
<span class="lineNum">    1104 </span>            : 
<span class="lineNum">    1105 </span>            :     CV_DbgAssert( m1.size() == m2.size() );
<span class="lineNum">    1106 </span>            : 
<span class="lineNum">    1107 </span>            :     for( y = 0; y &lt; rows; y++ )
<span class="lineNum">    1108 </span>            :     {
<span class="lineNum">    1109 </span>            :         const T1* src1 = m1[y];
<span class="lineNum">    1110 </span>            :         const T2* src2 = m2[y];
<span class="lineNum">    1111 </span>            :         T3* dst = m3[y];
<span class="lineNum">    1112 </span>            : 
<span class="lineNum">    1113 </span>            :         for( x = 0; x &lt; cols; x++ )
<span class="lineNum">    1114 </span>            :             dst[x] = op( src1[x], src2[x] );
<span class="lineNum">    1115 </span>            :     }
<span class="lineNum">    1116 </span>            : }
<span class="lineNum">    1117 </span>            : 
<span class="lineNum">    1118 </span>            : 
<span class="lineNum">    1119 </span>            : /////////////////////////////// Input/Output Arrays /////////////////////////////////
<span class="lineNum">    1120 </span>            : 
<span class="lineNum">    1121 </span>            : template&lt;typename _Tp&gt; inline _InputArray::_InputArray(const vector&lt;_Tp&gt;&amp; vec)
<span class="lineNum">    1122 </span><span class="lineNoCov">          0 :     : flags(FIXED_TYPE + STD_VECTOR + DataType&lt;_Tp&gt;::type), obj((void*)&amp;vec) {}</span>
<span class="lineNum">    1123 </span>            : 
<span class="lineNum">    1124 </span>            : template&lt;typename _Tp&gt; inline _InputArray::_InputArray(const vector&lt;vector&lt;_Tp&gt; &gt;&amp; vec)
<span class="lineNum">    1125 </span>            :     : flags(FIXED_TYPE + STD_VECTOR_VECTOR + DataType&lt;_Tp&gt;::type), obj((void*)&amp;vec) {}
<span class="lineNum">    1126 </span>            : 
<span class="lineNum">    1127 </span>            : template&lt;typename _Tp&gt; inline _InputArray::_InputArray(const vector&lt;Mat_&lt;_Tp&gt; &gt;&amp; vec)
<span class="lineNum">    1128 </span>            :     : flags(FIXED_TYPE + STD_VECTOR_MAT + DataType&lt;_Tp&gt;::type), obj((void*)&amp;vec) {}
<span class="lineNum">    1129 </span>            : 
<span class="lineNum">    1130 </span>            : template&lt;typename _Tp, int m, int n&gt; inline _InputArray::_InputArray(const Matx&lt;_Tp, m, n&gt;&amp; mtx)
<span class="lineNum">    1131 </span>            :     : flags(FIXED_TYPE + FIXED_SIZE + MATX + DataType&lt;_Tp&gt;::type), obj((void*)&amp;mtx), sz(n, m) {}
<span class="lineNum">    1132 </span>            : 
<span class="lineNum">    1133 </span>            : template&lt;typename _Tp&gt; inline _InputArray::_InputArray(const _Tp* vec, int n)
<span class="lineNum">    1134 </span>            :     : flags(FIXED_TYPE + FIXED_SIZE + MATX + DataType&lt;_Tp&gt;::type), obj((void*)vec), sz(n, 1) {}
<span class="lineNum">    1135 </span>            : 
<span class="lineNum">    1136 </span>            : inline _InputArray::_InputArray(const Scalar&amp; s)
<span class="lineNum">    1137 </span>            :     : flags(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F), obj((void*)&amp;s), sz(1, 4) {}
<span class="lineNum">    1138 </span>            : 
<span class="lineNum">    1139 </span>            : template&lt;typename _Tp&gt; inline _InputArray::_InputArray(const Mat_&lt;_Tp&gt;&amp; m)
<span class="lineNum">    1140 </span>            :     : flags(FIXED_TYPE + MAT + DataType&lt;_Tp&gt;::type), obj((void*)&amp;m) {}
<span class="lineNum">    1141 </span>            : 
<span class="lineNum">    1142 </span>            : template&lt;typename _Tp&gt; inline _OutputArray::_OutputArray(vector&lt;_Tp&gt;&amp; vec)
<span class="lineNum">    1143 </span>            :     : _InputArray(vec) {}
<span class="lineNum">    1144 </span>            : template&lt;typename _Tp&gt; inline _OutputArray::_OutputArray(vector&lt;vector&lt;_Tp&gt; &gt;&amp; vec)
<span class="lineNum">    1145 </span>            :     : _InputArray(vec) {}
<span class="lineNum">    1146 </span>            : template&lt;typename _Tp&gt; inline _OutputArray::_OutputArray(vector&lt;Mat_&lt;_Tp&gt; &gt;&amp; vec)
<span class="lineNum">    1147 </span>            :     : _InputArray(vec) {}
<span class="lineNum">    1148 </span>            : template&lt;typename _Tp&gt; inline _OutputArray::_OutputArray(Mat_&lt;_Tp&gt;&amp; m)
<span class="lineNum">    1149 </span>            :     : _InputArray(m) {}
<span class="lineNum">    1150 </span>            : template&lt;typename _Tp, int m, int n&gt; inline _OutputArray::_OutputArray(Matx&lt;_Tp, m, n&gt;&amp; mtx)
<span class="lineNum">    1151 </span>            :     : _InputArray(mtx) {}
<span class="lineNum">    1152 </span>            : template&lt;typename _Tp&gt; inline _OutputArray::_OutputArray(_Tp* vec, int n)
<span class="lineNum">    1153 </span>            :     : _InputArray(vec, n) {}
<span class="lineNum">    1154 </span>            : 
<span class="lineNum">    1155 </span>            : template&lt;typename _Tp&gt; inline _OutputArray::_OutputArray(const vector&lt;_Tp&gt;&amp; vec)
<span class="lineNum">    1156 </span>            :     : _InputArray(vec) {flags |= FIXED_SIZE;}
<span class="lineNum">    1157 </span>            : template&lt;typename _Tp&gt; inline _OutputArray::_OutputArray(const vector&lt;vector&lt;_Tp&gt; &gt;&amp; vec)
<span class="lineNum">    1158 </span>            :     : _InputArray(vec) {flags |= FIXED_SIZE;}
<span class="lineNum">    1159 </span>            : template&lt;typename _Tp&gt; inline _OutputArray::_OutputArray(const vector&lt;Mat_&lt;_Tp&gt; &gt;&amp; vec)
<span class="lineNum">    1160 </span>            :     : _InputArray(vec) {flags |= FIXED_SIZE;}
<span class="lineNum">    1161 </span>            : 
<span class="lineNum">    1162 </span>            : template&lt;typename _Tp&gt; inline _OutputArray::_OutputArray(const Mat_&lt;_Tp&gt;&amp; m)
<span class="lineNum">    1163 </span>            :     : _InputArray(m) {flags |= FIXED_SIZE;}
<span class="lineNum">    1164 </span>            : template&lt;typename _Tp, int m, int n&gt; inline _OutputArray::_OutputArray(const Matx&lt;_Tp, m, n&gt;&amp; mtx)
<span class="lineNum">    1165 </span>            :     : _InputArray(mtx) {}
<span class="lineNum">    1166 </span>            : template&lt;typename _Tp&gt; inline _OutputArray::_OutputArray(const _Tp* vec, int n)
<span class="lineNum">    1167 </span>            :     : _InputArray(vec, n) {}
<span class="lineNum">    1168 </span>            : 
<span class="lineNum">    1169 </span>            : //////////////////////////////////// Matrix Expressions /////////////////////////////////////////
<span class="lineNum">    1170 </span>            : 
<span class="lineNum">    1171 </span>            : class CV_EXPORTS MatOp
<span class="lineNum">    1172 </span>            : {
<span class="lineNum">    1173 </span>            : public:
<span class="lineNum">    1174 </span>            :     MatOp() {};
<span class="lineNum">    1175 </span>            :     virtual ~MatOp() {};
<span class="lineNum">    1176 </span>            : 
<span class="lineNum">    1177 </span>            :     virtual bool elementWise(const MatExpr&amp; expr) const;
<span class="lineNum">    1178 </span>            :     virtual void assign(const MatExpr&amp; expr, Mat&amp; m, int type=-1) const = 0;
<span class="lineNum">    1179 </span>            :     virtual void roi(const MatExpr&amp; expr, const Range&amp; rowRange,
<span class="lineNum">    1180 </span>            :                      const Range&amp; colRange, MatExpr&amp; res) const;
<span class="lineNum">    1181 </span>            :     virtual void diag(const MatExpr&amp; expr, int d, MatExpr&amp; res) const;
<span class="lineNum">    1182 </span>            :     virtual void augAssignAdd(const MatExpr&amp; expr, Mat&amp; m) const;
<span class="lineNum">    1183 </span>            :     virtual void augAssignSubtract(const MatExpr&amp; expr, Mat&amp; m) const;
<span class="lineNum">    1184 </span>            :     virtual void augAssignMultiply(const MatExpr&amp; expr, Mat&amp; m) const;
<span class="lineNum">    1185 </span>            :     virtual void augAssignDivide(const MatExpr&amp; expr, Mat&amp; m) const;
<span class="lineNum">    1186 </span>            :     virtual void augAssignAnd(const MatExpr&amp; expr, Mat&amp; m) const;
<span class="lineNum">    1187 </span>            :     virtual void augAssignOr(const MatExpr&amp; expr, Mat&amp; m) const;
<span class="lineNum">    1188 </span>            :     virtual void augAssignXor(const MatExpr&amp; expr, Mat&amp; m) const;
<span class="lineNum">    1189 </span>            : 
<span class="lineNum">    1190 </span>            :     virtual void add(const MatExpr&amp; expr1, const MatExpr&amp; expr2, MatExpr&amp; res) const;
<span class="lineNum">    1191 </span>            :     virtual void add(const MatExpr&amp; expr1, const Scalar&amp; s, MatExpr&amp; res) const;
<span class="lineNum">    1192 </span>            : 
<span class="lineNum">    1193 </span>            :     virtual void subtract(const MatExpr&amp; expr1, const MatExpr&amp; expr2, MatExpr&amp; res) const;
<span class="lineNum">    1194 </span>            :     virtual void subtract(const Scalar&amp; s, const MatExpr&amp; expr, MatExpr&amp; res) const;
<span class="lineNum">    1195 </span>            : 
<span class="lineNum">    1196 </span>            :     virtual void multiply(const MatExpr&amp; expr1, const MatExpr&amp; expr2, MatExpr&amp; res, double scale=1) const;
<span class="lineNum">    1197 </span>            :     virtual void multiply(const MatExpr&amp; expr1, double s, MatExpr&amp; res) const;
<span class="lineNum">    1198 </span>            : 
<span class="lineNum">    1199 </span>            :     virtual void divide(const MatExpr&amp; expr1, const MatExpr&amp; expr2, MatExpr&amp; res, double scale=1) const;
<span class="lineNum">    1200 </span>            :     virtual void divide(double s, const MatExpr&amp; expr, MatExpr&amp; res) const;
<span class="lineNum">    1201 </span>            : 
<span class="lineNum">    1202 </span>            :     virtual void abs(const MatExpr&amp; expr, MatExpr&amp; res) const;
<span class="lineNum">    1203 </span>            : 
<span class="lineNum">    1204 </span>            :     virtual void transpose(const MatExpr&amp; expr, MatExpr&amp; res) const;
<span class="lineNum">    1205 </span>            :     virtual void matmul(const MatExpr&amp; expr1, const MatExpr&amp; expr2, MatExpr&amp; res) const;
<span class="lineNum">    1206 </span>            :     virtual void invert(const MatExpr&amp; expr, int method, MatExpr&amp; res) const;
<span class="lineNum">    1207 </span>            : 
<span class="lineNum">    1208 </span>            :     virtual Size size(const MatExpr&amp; expr) const;
<span class="lineNum">    1209 </span>            :     virtual int type(const MatExpr&amp; expr) const;
<span class="lineNum">    1210 </span>            : };
<span class="lineNum">    1211 </span>            : 
<span class="lineNum">    1212 </span>            : 
<span class="lineNum">    1213 </span>            : class CV_EXPORTS MatExpr
<span class="lineNum">    1214 </span>            : {
<span class="lineNum">    1215 </span>            : public:
<span class="lineNum">    1216 </span>            :     MatExpr() : op(0), flags(0), a(Mat()), b(Mat()), c(Mat()), alpha(0), beta(0), s(Scalar()) {}
<span class="lineNum">    1217 </span>            :     MatExpr(const MatOp* _op, int _flags, const Mat&amp; _a=Mat(), const Mat&amp; _b=Mat(),
<span class="lineNum">    1218 </span>            :             const Mat&amp; _c=Mat(), double _alpha=1, double _beta=1, const Scalar&amp; _s=Scalar())
<span class="lineNum">    1219 </span>            :         : op(_op), flags(_flags), a(_a), b(_b), c(_c), alpha(_alpha), beta(_beta), s(_s) {}
<span class="lineNum">    1220 </span>            :     explicit MatExpr(const Mat&amp; m);
<span class="lineNum">    1221 </span>            :     operator Mat() const
<span class="lineNum">    1222 </span>            :     {
<span class="lineNum">    1223 </span>            :         Mat m;
<span class="lineNum">    1224 </span>            :         op-&gt;assign(*this, m);
<span class="lineNum">    1225 </span>            :         return m;
<span class="lineNum">    1226 </span>            :     }
<span class="lineNum">    1227 </span>            : 
<span class="lineNum">    1228 </span>            :     template&lt;typename _Tp&gt; operator Mat_&lt;_Tp&gt;() const
<span class="lineNum">    1229 </span>            :     {
<span class="lineNum">    1230 </span>            :         Mat_&lt;_Tp&gt; m;
<span class="lineNum">    1231 </span>            :         op-&gt;assign(*this, m, DataType&lt;_Tp&gt;::type);
<span class="lineNum">    1232 </span>            :         return m;
<span class="lineNum">    1233 </span>            :     }
<span class="lineNum">    1234 </span>            : 
<span class="lineNum">    1235 </span>            :     MatExpr row(int y) const;
<span class="lineNum">    1236 </span>            :     MatExpr col(int x) const;
<span class="lineNum">    1237 </span>            :     MatExpr diag(int d=0) const;
<span class="lineNum">    1238 </span>            :     MatExpr operator()( const Range&amp; rowRange, const Range&amp; colRange ) const;
<span class="lineNum">    1239 </span>            :     MatExpr operator()( const Rect&amp; roi ) const;
<span class="lineNum">    1240 </span>            : 
<span class="lineNum">    1241 </span>            :     Mat cross(const Mat&amp; m) const;
<span class="lineNum">    1242 </span>            :     double dot(const Mat&amp; m) const;
<span class="lineNum">    1243 </span>            : 
<span class="lineNum">    1244 </span>            :     MatExpr t() const;
<span class="lineNum">    1245 </span>            :     MatExpr inv(int method = DECOMP_LU) const;
<span class="lineNum">    1246 </span>            :     MatExpr mul(const MatExpr&amp; e, double scale=1) const;
<span class="lineNum">    1247 </span>            :     MatExpr mul(const Mat&amp; m, double scale=1) const;
<span class="lineNum">    1248 </span>            : 
<span class="lineNum">    1249 </span>            :     Size size() const;
<span class="lineNum">    1250 </span>            :     int type() const;
<span class="lineNum">    1251 </span>            : 
<span class="lineNum">    1252 </span>            :     const MatOp* op;
<span class="lineNum">    1253 </span>            :     int flags;
<span class="lineNum">    1254 </span>            : 
<span class="lineNum">    1255 </span>            :     Mat a, b, c;
<span class="lineNum">    1256 </span>            :     double alpha, beta;
<span class="lineNum">    1257 </span>            :     Scalar s;
<span class="lineNum">    1258 </span>            : };
<span class="lineNum">    1259 </span>            : 
<span class="lineNum">    1260 </span>            : 
<span class="lineNum">    1261 </span>            : CV_EXPORTS MatExpr operator + (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1262 </span>            : CV_EXPORTS MatExpr operator + (const Mat&amp; a, const Scalar&amp; s);
<span class="lineNum">    1263 </span>            : CV_EXPORTS MatExpr operator + (const Scalar&amp; s, const Mat&amp; a);
<span class="lineNum">    1264 </span>            : CV_EXPORTS MatExpr operator + (const MatExpr&amp; e, const Mat&amp; m);
<span class="lineNum">    1265 </span>            : CV_EXPORTS MatExpr operator + (const Mat&amp; m, const MatExpr&amp; e);
<span class="lineNum">    1266 </span>            : CV_EXPORTS MatExpr operator + (const MatExpr&amp; e, const Scalar&amp; s);
<span class="lineNum">    1267 </span>            : CV_EXPORTS MatExpr operator + (const Scalar&amp; s, const MatExpr&amp; e);
<span class="lineNum">    1268 </span>            : CV_EXPORTS MatExpr operator + (const MatExpr&amp; e1, const MatExpr&amp; e2);
<span class="lineNum">    1269 </span>            : 
<span class="lineNum">    1270 </span>            : CV_EXPORTS MatExpr operator - (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1271 </span>            : CV_EXPORTS MatExpr operator - (const Mat&amp; a, const Scalar&amp; s);
<span class="lineNum">    1272 </span>            : CV_EXPORTS MatExpr operator - (const Scalar&amp; s, const Mat&amp; a);
<span class="lineNum">    1273 </span>            : CV_EXPORTS MatExpr operator - (const MatExpr&amp; e, const Mat&amp; m);
<span class="lineNum">    1274 </span>            : CV_EXPORTS MatExpr operator - (const Mat&amp; m, const MatExpr&amp; e);
<span class="lineNum">    1275 </span>            : CV_EXPORTS MatExpr operator - (const MatExpr&amp; e, const Scalar&amp; s);
<span class="lineNum">    1276 </span>            : CV_EXPORTS MatExpr operator - (const Scalar&amp; s, const MatExpr&amp; e);
<span class="lineNum">    1277 </span>            : CV_EXPORTS MatExpr operator - (const MatExpr&amp; e1, const MatExpr&amp; e2);
<span class="lineNum">    1278 </span>            : 
<span class="lineNum">    1279 </span>            : CV_EXPORTS MatExpr operator - (const Mat&amp; m);
<span class="lineNum">    1280 </span>            : CV_EXPORTS MatExpr operator - (const MatExpr&amp; e);
<span class="lineNum">    1281 </span>            : 
<span class="lineNum">    1282 </span>            : CV_EXPORTS MatExpr operator * (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1283 </span>            : CV_EXPORTS MatExpr operator * (const Mat&amp; a, double s);
<span class="lineNum">    1284 </span>            : CV_EXPORTS MatExpr operator * (double s, const Mat&amp; a);
<span class="lineNum">    1285 </span>            : CV_EXPORTS MatExpr operator * (const MatExpr&amp; e, const Mat&amp; m);
<span class="lineNum">    1286 </span>            : CV_EXPORTS MatExpr operator * (const Mat&amp; m, const MatExpr&amp; e);
<span class="lineNum">    1287 </span>            : CV_EXPORTS MatExpr operator * (const MatExpr&amp; e, double s);
<span class="lineNum">    1288 </span>            : CV_EXPORTS MatExpr operator * (double s, const MatExpr&amp; e);
<span class="lineNum">    1289 </span>            : CV_EXPORTS MatExpr operator * (const MatExpr&amp; e1, const MatExpr&amp; e2);
<span class="lineNum">    1290 </span>            : 
<span class="lineNum">    1291 </span>            : CV_EXPORTS MatExpr operator / (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1292 </span>            : CV_EXPORTS MatExpr operator / (const Mat&amp; a, double s);
<span class="lineNum">    1293 </span>            : CV_EXPORTS MatExpr operator / (double s, const Mat&amp; a);
<span class="lineNum">    1294 </span>            : CV_EXPORTS MatExpr operator / (const MatExpr&amp; e, const Mat&amp; m);
<span class="lineNum">    1295 </span>            : CV_EXPORTS MatExpr operator / (const Mat&amp; m, const MatExpr&amp; e);
<span class="lineNum">    1296 </span>            : CV_EXPORTS MatExpr operator / (const MatExpr&amp; e, double s);
<span class="lineNum">    1297 </span>            : CV_EXPORTS MatExpr operator / (double s, const MatExpr&amp; e);
<span class="lineNum">    1298 </span>            : CV_EXPORTS MatExpr operator / (const MatExpr&amp; e1, const MatExpr&amp; e2);
<span class="lineNum">    1299 </span>            : 
<span class="lineNum">    1300 </span>            : CV_EXPORTS MatExpr operator &lt; (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1301 </span>            : CV_EXPORTS MatExpr operator &lt; (const Mat&amp; a, double s);
<span class="lineNum">    1302 </span>            : CV_EXPORTS MatExpr operator &lt; (double s, const Mat&amp; a);
<span class="lineNum">    1303 </span>            : 
<span class="lineNum">    1304 </span>            : CV_EXPORTS MatExpr operator &lt;= (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1305 </span>            : CV_EXPORTS MatExpr operator &lt;= (const Mat&amp; a, double s);
<span class="lineNum">    1306 </span>            : CV_EXPORTS MatExpr operator &lt;= (double s, const Mat&amp; a);
<span class="lineNum">    1307 </span>            : 
<span class="lineNum">    1308 </span>            : CV_EXPORTS MatExpr operator == (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1309 </span>            : CV_EXPORTS MatExpr operator == (const Mat&amp; a, double s);
<span class="lineNum">    1310 </span>            : CV_EXPORTS MatExpr operator == (double s, const Mat&amp; a);
<span class="lineNum">    1311 </span>            : 
<span class="lineNum">    1312 </span>            : CV_EXPORTS MatExpr operator != (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1313 </span>            : CV_EXPORTS MatExpr operator != (const Mat&amp; a, double s);
<span class="lineNum">    1314 </span>            : CV_EXPORTS MatExpr operator != (double s, const Mat&amp; a);
<span class="lineNum">    1315 </span>            : 
<span class="lineNum">    1316 </span>            : CV_EXPORTS MatExpr operator &gt;= (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1317 </span>            : CV_EXPORTS MatExpr operator &gt;= (const Mat&amp; a, double s);
<span class="lineNum">    1318 </span>            : CV_EXPORTS MatExpr operator &gt;= (double s, const Mat&amp; a);
<span class="lineNum">    1319 </span>            : 
<span class="lineNum">    1320 </span>            : CV_EXPORTS MatExpr operator &gt; (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1321 </span>            : CV_EXPORTS MatExpr operator &gt; (const Mat&amp; a, double s);
<span class="lineNum">    1322 </span>            : CV_EXPORTS MatExpr operator &gt; (double s, const Mat&amp; a);
<span class="lineNum">    1323 </span>            : 
<span class="lineNum">    1324 </span>            : CV_EXPORTS MatExpr min(const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1325 </span>            : CV_EXPORTS MatExpr min(const Mat&amp; a, double s);
<span class="lineNum">    1326 </span>            : CV_EXPORTS MatExpr min(double s, const Mat&amp; a);
<span class="lineNum">    1327 </span>            : 
<span class="lineNum">    1328 </span>            : CV_EXPORTS MatExpr max(const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1329 </span>            : CV_EXPORTS MatExpr max(const Mat&amp; a, double s);
<span class="lineNum">    1330 </span>            : CV_EXPORTS MatExpr max(double s, const Mat&amp; a);
<span class="lineNum">    1331 </span>            : 
<span class="lineNum">    1332 </span>            : template&lt;typename _Tp&gt; static inline MatExpr min(const Mat_&lt;_Tp&gt;&amp; a, const Mat_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1333 </span>            : {
<span class="lineNum">    1334 </span>            :     return cv::min((const Mat&amp;)a, (const Mat&amp;)b);
<span class="lineNum">    1335 </span>            : }
<span class="lineNum">    1336 </span>            : 
<span class="lineNum">    1337 </span>            : template&lt;typename _Tp&gt; static inline MatExpr min(const Mat_&lt;_Tp&gt;&amp; a, double s)
<span class="lineNum">    1338 </span>            : {
<span class="lineNum">    1339 </span>            :     return cv::min((const Mat&amp;)a, s);
<span class="lineNum">    1340 </span>            : }
<span class="lineNum">    1341 </span>            : 
<span class="lineNum">    1342 </span>            : template&lt;typename _Tp&gt; static inline MatExpr min(double s, const Mat_&lt;_Tp&gt;&amp; a)
<span class="lineNum">    1343 </span>            : {
<span class="lineNum">    1344 </span>            :     return cv::min((const Mat&amp;)a, s);
<span class="lineNum">    1345 </span>            : }
<span class="lineNum">    1346 </span>            : 
<span class="lineNum">    1347 </span>            : template&lt;typename _Tp&gt; static inline MatExpr max(const Mat_&lt;_Tp&gt;&amp; a, const Mat_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1348 </span>            : {
<span class="lineNum">    1349 </span>            :     return cv::max((const Mat&amp;)a, (const Mat&amp;)b);
<span class="lineNum">    1350 </span>            : }
<span class="lineNum">    1351 </span>            : 
<span class="lineNum">    1352 </span>            : template&lt;typename _Tp&gt; static inline MatExpr max(const Mat_&lt;_Tp&gt;&amp; a, double s)
<span class="lineNum">    1353 </span>            : {
<span class="lineNum">    1354 </span>            :     return cv::max((const Mat&amp;)a, s);
<span class="lineNum">    1355 </span>            : }
<span class="lineNum">    1356 </span>            : 
<span class="lineNum">    1357 </span>            : template&lt;typename _Tp&gt; static inline MatExpr max(double s, const Mat_&lt;_Tp&gt;&amp; a)
<span class="lineNum">    1358 </span>            : {
<span class="lineNum">    1359 </span>            :     return cv::max((const Mat&amp;)a, s);
<span class="lineNum">    1360 </span>            : }
<span class="lineNum">    1361 </span>            : 
<span class="lineNum">    1362 </span>            : template&lt;typename _Tp&gt; static inline void min(const Mat_&lt;_Tp&gt;&amp; a, const Mat_&lt;_Tp&gt;&amp; b, Mat_&lt;_Tp&gt;&amp; c)
<span class="lineNum">    1363 </span>            : {
<span class="lineNum">    1364 </span>            :     cv::min((const Mat&amp;)a, (const Mat&amp;)b, (Mat&amp;)c);
<span class="lineNum">    1365 </span>            : }
<span class="lineNum">    1366 </span>            : 
<span class="lineNum">    1367 </span>            : template&lt;typename _Tp&gt; static inline void min(const Mat_&lt;_Tp&gt;&amp; a, double s, Mat_&lt;_Tp&gt;&amp; c)
<span class="lineNum">    1368 </span>            : {
<span class="lineNum">    1369 </span>            :     cv::min((const Mat&amp;)a, s, (Mat&amp;)c);
<span class="lineNum">    1370 </span>            : }
<span class="lineNum">    1371 </span>            : 
<span class="lineNum">    1372 </span>            : template&lt;typename _Tp&gt; static inline void min(double s, const Mat_&lt;_Tp&gt;&amp; a, Mat_&lt;_Tp&gt;&amp; c)
<span class="lineNum">    1373 </span>            : {
<span class="lineNum">    1374 </span>            :     cv::min((const Mat&amp;)a, s, (Mat&amp;)c);
<span class="lineNum">    1375 </span>            : }
<span class="lineNum">    1376 </span>            : 
<span class="lineNum">    1377 </span>            : template&lt;typename _Tp&gt; static inline void max(const Mat_&lt;_Tp&gt;&amp; a, const Mat_&lt;_Tp&gt;&amp; b, Mat_&lt;_Tp&gt;&amp; c)
<span class="lineNum">    1378 </span>            : {
<span class="lineNum">    1379 </span>            :     cv::max((const Mat&amp;)a, (const Mat&amp;)b, (Mat&amp;)c);
<span class="lineNum">    1380 </span>            : }
<span class="lineNum">    1381 </span>            : 
<span class="lineNum">    1382 </span>            : template&lt;typename _Tp&gt; static inline void max(const Mat_&lt;_Tp&gt;&amp; a, double s, Mat_&lt;_Tp&gt;&amp; c)
<span class="lineNum">    1383 </span>            : {
<span class="lineNum">    1384 </span>            :     cv::max((const Mat&amp;)a, s, (Mat&amp;)c);
<span class="lineNum">    1385 </span>            : }
<span class="lineNum">    1386 </span>            : 
<span class="lineNum">    1387 </span>            : template&lt;typename _Tp&gt; static inline void max(double s, const Mat_&lt;_Tp&gt;&amp; a, Mat_&lt;_Tp&gt;&amp; c)
<span class="lineNum">    1388 </span>            : {
<span class="lineNum">    1389 </span>            :     cv::max((const Mat&amp;)a, s, (Mat&amp;)c);
<span class="lineNum">    1390 </span>            : }
<span class="lineNum">    1391 </span>            : 
<span class="lineNum">    1392 </span>            : 
<span class="lineNum">    1393 </span>            : CV_EXPORTS MatExpr operator &amp; (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1394 </span>            : CV_EXPORTS MatExpr operator &amp; (const Mat&amp; a, const Scalar&amp; s);
<span class="lineNum">    1395 </span>            : CV_EXPORTS MatExpr operator &amp; (const Scalar&amp; s, const Mat&amp; a);
<span class="lineNum">    1396 </span>            : 
<span class="lineNum">    1397 </span>            : CV_EXPORTS MatExpr operator | (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1398 </span>            : CV_EXPORTS MatExpr operator | (const Mat&amp; a, const Scalar&amp; s);
<span class="lineNum">    1399 </span>            : CV_EXPORTS MatExpr operator | (const Scalar&amp; s, const Mat&amp; a);
<span class="lineNum">    1400 </span>            : 
<span class="lineNum">    1401 </span>            : CV_EXPORTS MatExpr operator ^ (const Mat&amp; a, const Mat&amp; b);
<span class="lineNum">    1402 </span>            : CV_EXPORTS MatExpr operator ^ (const Mat&amp; a, const Scalar&amp; s);
<span class="lineNum">    1403 </span>            : CV_EXPORTS MatExpr operator ^ (const Scalar&amp; s, const Mat&amp; a);
<span class="lineNum">    1404 </span>            : 
<span class="lineNum">    1405 </span>            : CV_EXPORTS MatExpr operator ~(const Mat&amp; m);
<span class="lineNum">    1406 </span>            : 
<span class="lineNum">    1407 </span>            : CV_EXPORTS MatExpr abs(const Mat&amp; m);
<span class="lineNum">    1408 </span>            : CV_EXPORTS MatExpr abs(const MatExpr&amp; e);
<span class="lineNum">    1409 </span>            : 
<span class="lineNum">    1410 </span>            : template&lt;typename _Tp&gt; static inline MatExpr abs(const Mat_&lt;_Tp&gt;&amp; m)
<span class="lineNum">    1411 </span>            : {
<span class="lineNum">    1412 </span>            :     return cv::abs((const Mat&amp;)m);
<span class="lineNum">    1413 </span>            : }
<span class="lineNum">    1414 </span>            : 
<span class="lineNum">    1415 </span>            : ////////////////////////////// Augmenting algebraic operations //////////////////////////////////
<span class="lineNum">    1416 </span>            : 
<span class="lineNum">    1417 </span>            : inline Mat&amp; Mat::operator = (const MatExpr&amp; e)
<span class="lineNum">    1418 </span>            : {
<span class="lineNum">    1419 </span>            :     e.op-&gt;assign(e, *this);
<span class="lineNum">    1420 </span>            :     return *this;
<span class="lineNum">    1421 </span>            : }
<span class="lineNum">    1422 </span>            : 
<span class="lineNum">    1423 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt;::Mat_(const MatExpr&amp; e)
<span class="lineNum">    1424 </span>            : {
<span class="lineNum">    1425 </span>            :     e.op-&gt;assign(e, *this, DataType&lt;_Tp&gt;::type);
<span class="lineNum">    1426 </span>            : }
<span class="lineNum">    1427 </span>            : 
<span class="lineNum">    1428 </span>            : template&lt;typename _Tp&gt; Mat_&lt;_Tp&gt;&amp; Mat_&lt;_Tp&gt;::operator = (const MatExpr&amp; e)
<span class="lineNum">    1429 </span>            : {
<span class="lineNum">    1430 </span>            :     e.op-&gt;assign(e, *this, DataType&lt;_Tp&gt;::type);
<span class="lineNum">    1431 </span>            :     return *this;
<span class="lineNum">    1432 </span>            : }
<span class="lineNum">    1433 </span>            : 
<span class="lineNum">    1434 </span>            : static inline Mat&amp; operator += (const Mat&amp; a, const Mat&amp; b)
<span class="lineNum">    1435 </span>            : {
<span class="lineNum">    1436 </span>            :     add(a, b, (Mat&amp;)a);
<span class="lineNum">    1437 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1438 </span>            : }
<span class="lineNum">    1439 </span>            : 
<span class="lineNum">    1440 </span>            : static inline Mat&amp; operator += (const Mat&amp; a, const Scalar&amp; s)
<span class="lineNum">    1441 </span>            : {
<span class="lineNum">    1442 </span>            :     add(a, s, (Mat&amp;)a);
<span class="lineNum">    1443 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1444 </span>            : }
<span class="lineNum">    1445 </span>            : 
<span class="lineNum">    1446 </span>            : template&lt;typename _Tp&gt; static inline
<span class="lineNum">    1447 </span>            : Mat_&lt;_Tp&gt;&amp; operator += (const Mat_&lt;_Tp&gt;&amp; a, const Mat_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1448 </span>            : {
<span class="lineNum">    1449 </span>            :     add(a, b, (Mat&amp;)a);
<span class="lineNum">    1450 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1451 </span>            : }
<span class="lineNum">    1452 </span>            : 
<span class="lineNum">    1453 </span>            : template&lt;typename _Tp&gt; static inline
<span class="lineNum">    1454 </span>            : Mat_&lt;_Tp&gt;&amp; operator += (const Mat_&lt;_Tp&gt;&amp; a, const Scalar&amp; s)
<span class="lineNum">    1455 </span>            : {
<span class="lineNum">    1456 </span>            :     add(a, s, (Mat&amp;)a);
<span class="lineNum">    1457 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1458 </span>            : }
<span class="lineNum">    1459 </span>            : 
<span class="lineNum">    1460 </span>            : static inline Mat&amp; operator += (const Mat&amp; a, const MatExpr&amp; b)
<span class="lineNum">    1461 </span>            : {
<span class="lineNum">    1462 </span>            :     b.op-&gt;augAssignAdd(b, (Mat&amp;)a);
<span class="lineNum">    1463 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1464 </span>            : }
<span class="lineNum">    1465 </span>            : 
<span class="lineNum">    1466 </span>            : template&lt;typename _Tp&gt; static inline
<span class="lineNum">    1467 </span>            : Mat_&lt;_Tp&gt;&amp; operator += (const Mat_&lt;_Tp&gt;&amp; a, const MatExpr&amp; b)
<span class="lineNum">    1468 </span>            : {
<span class="lineNum">    1469 </span>            :     b.op-&gt;augAssignAdd(b, (Mat&amp;)a);
<span class="lineNum">    1470 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1471 </span>            : }
<span class="lineNum">    1472 </span>            : 
<span class="lineNum">    1473 </span>            : static inline Mat&amp; operator -= (const Mat&amp; a, const Mat&amp; b)
<span class="lineNum">    1474 </span>            : {
<span class="lineNum">    1475 </span>            :     subtract(a, b, (Mat&amp;)a);
<span class="lineNum">    1476 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1477 </span>            : }
<span class="lineNum">    1478 </span>            : 
<span class="lineNum">    1479 </span>            : static inline Mat&amp; operator -= (const Mat&amp; a, const Scalar&amp; s)
<span class="lineNum">    1480 </span>            : {
<span class="lineNum">    1481 </span>            :     subtract(a, s, (Mat&amp;)a);
<span class="lineNum">    1482 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1483 </span>            : }
<span class="lineNum">    1484 </span>            : 
<span class="lineNum">    1485 </span>            : template&lt;typename _Tp&gt; static inline
<span class="lineNum">    1486 </span>            : Mat_&lt;_Tp&gt;&amp; operator -= (const Mat_&lt;_Tp&gt;&amp; a, const Mat_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1487 </span>            : {
<span class="lineNum">    1488 </span>            :     subtract(a, b, (Mat&amp;)a);
<span class="lineNum">    1489 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1490 </span>            : }
<span class="lineNum">    1491 </span>            : 
<span class="lineNum">    1492 </span>            : template&lt;typename _Tp&gt; static inline
<span class="lineNum">    1493 </span>            : Mat_&lt;_Tp&gt;&amp; operator -= (const Mat_&lt;_Tp&gt;&amp; a, const Scalar&amp; s)
<span class="lineNum">    1494 </span>            : {
<span class="lineNum">    1495 </span>            :     subtract(a, s, (Mat&amp;)a);
<span class="lineNum">    1496 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1497 </span>            : }
<span class="lineNum">    1498 </span>            : 
<span class="lineNum">    1499 </span>            : static inline Mat&amp; operator -= (const Mat&amp; a, const MatExpr&amp; b)
<span class="lineNum">    1500 </span>            : {
<span class="lineNum">    1501 </span>            :     b.op-&gt;augAssignSubtract(b, (Mat&amp;)a);
<span class="lineNum">    1502 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1503 </span>            : }
<span class="lineNum">    1504 </span>            : 
<span class="lineNum">    1505 </span>            : template&lt;typename _Tp&gt; static inline
<span class="lineNum">    1506 </span>            : Mat_&lt;_Tp&gt;&amp; operator -= (const Mat_&lt;_Tp&gt;&amp; a, const MatExpr&amp; b)
<span class="lineNum">    1507 </span>            : {
<span class="lineNum">    1508 </span>            :     b.op-&gt;augAssignSubtract(b, (Mat&amp;)a);
<span class="lineNum">    1509 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1510 </span>            : }
<span class="lineNum">    1511 </span>            : 
<span class="lineNum">    1512 </span>            : static inline Mat&amp; operator *= (const Mat&amp; a, const Mat&amp; b)
<span class="lineNum">    1513 </span>            : {
<span class="lineNum">    1514 </span>            :     gemm(a, b, 1, Mat(), 0, (Mat&amp;)a, 0);
<span class="lineNum">    1515 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1516 </span>            : }
<span class="lineNum">    1517 </span>            : 
<span class="lineNum">    1518 </span>            : static inline Mat&amp; operator *= (const Mat&amp; a, double s)
<span class="lineNum">    1519 </span>            : {
<span class="lineNum">    1520 </span>            :     a.convertTo((Mat&amp;)a, -1, s);
<span class="lineNum">    1521 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1522 </span>            : }
<span class="lineNum">    1523 </span>            : 
<span class="lineNum">    1524 </span>            : template&lt;typename _Tp&gt; static inline
<span class="lineNum">    1525 </span>            : Mat_&lt;_Tp&gt;&amp; operator *= (const Mat_&lt;_Tp&gt;&amp; a, const Mat_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1526 </span>            : {
<span class="lineNum">    1527 </span>            :     gemm(a, b, 1, Mat(), 0, (Mat&amp;)a, 0);
<span class="lineNum">    1528 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1529 </span>            : }
<span class="lineNum">    1530 </span>            : 
<span class="lineNum">    1531 </span>            : template&lt;typename _Tp&gt; static inline
<span class="lineNum">    1532 </span>            : Mat_&lt;_Tp&gt;&amp; operator *= (const Mat_&lt;_Tp&gt;&amp; a, double s)
<span class="lineNum">    1533 </span>            : {
<span class="lineNum">    1534 </span>            :     a.convertTo((Mat&amp;)a, -1, s);
<span class="lineNum">    1535 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1536 </span>            : }
<span class="lineNum">    1537 </span>            : 
<span class="lineNum">    1538 </span>            : static inline Mat&amp; operator *= (const Mat&amp; a, const MatExpr&amp; b)
<span class="lineNum">    1539 </span>            : {
<span class="lineNum">    1540 </span>            :     b.op-&gt;augAssignMultiply(b, (Mat&amp;)a);
<span class="lineNum">    1541 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1542 </span>            : }
<span class="lineNum">    1543 </span>            : 
<span class="lineNum">    1544 </span>            : template&lt;typename _Tp&gt; static inline
<span class="lineNum">    1545 </span>            : Mat_&lt;_Tp&gt;&amp; operator *= (const Mat_&lt;_Tp&gt;&amp; a, const MatExpr&amp; b)
<span class="lineNum">    1546 </span>            : {
<span class="lineNum">    1547 </span>            :     b.op-&gt;augAssignMultiply(b, (Mat&amp;)a);
<span class="lineNum">    1548 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1549 </span>            : }
<span class="lineNum">    1550 </span>            : 
<span class="lineNum">    1551 </span>            : static inline Mat&amp; operator /= (const Mat&amp; a, const Mat&amp; b)
<span class="lineNum">    1552 </span>            : {
<span class="lineNum">    1553 </span>            :     divide(a, b, (Mat&amp;)a);
<span class="lineNum">    1554 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1555 </span>            : }
<span class="lineNum">    1556 </span>            : 
<span class="lineNum">    1557 </span>            : static inline Mat&amp; operator /= (const Mat&amp; a, double s)
<span class="lineNum">    1558 </span>            : {
<span class="lineNum">    1559 </span>            :     a.convertTo((Mat&amp;)a, -1, 1./s);
<span class="lineNum">    1560 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1561 </span>            : }
<span class="lineNum">    1562 </span>            : 
<span class="lineNum">    1563 </span>            : template&lt;typename _Tp&gt; static inline
<span class="lineNum">    1564 </span>            : Mat_&lt;_Tp&gt;&amp; operator /= (const Mat_&lt;_Tp&gt;&amp; a, const Mat_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1565 </span>            : {
<span class="lineNum">    1566 </span>            :     divide(a, b, (Mat&amp;)a);
<span class="lineNum">    1567 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1568 </span>            : }
<span class="lineNum">    1569 </span>            : 
<span class="lineNum">    1570 </span>            : template&lt;typename _Tp&gt; static inline
<span class="lineNum">    1571 </span>            : Mat_&lt;_Tp&gt;&amp; operator /= (const Mat_&lt;_Tp&gt;&amp; a, double s)
<span class="lineNum">    1572 </span>            : {
<span class="lineNum">    1573 </span>            :     a.convertTo((Mat&amp;)a, -1, 1./s);
<span class="lineNum">    1574 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1575 </span>            : }
<span class="lineNum">    1576 </span>            : 
<span class="lineNum">    1577 </span>            : static inline Mat&amp; operator /= (const Mat&amp; a, const MatExpr&amp; b)
<span class="lineNum">    1578 </span>            : {
<span class="lineNum">    1579 </span>            :     b.op-&gt;augAssignDivide(b, (Mat&amp;)a);
<span class="lineNum">    1580 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1581 </span>            : }
<span class="lineNum">    1582 </span>            : 
<span class="lineNum">    1583 </span>            : template&lt;typename _Tp&gt; static inline
<span class="lineNum">    1584 </span>            : Mat_&lt;_Tp&gt;&amp; operator /= (const Mat_&lt;_Tp&gt;&amp; a, const MatExpr&amp; b)
<span class="lineNum">    1585 </span>            : {
<span class="lineNum">    1586 </span>            :     b.op-&gt;augAssignDivide(b, (Mat&amp;)a);
<span class="lineNum">    1587 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1588 </span>            : }
<span class="lineNum">    1589 </span>            : 
<span class="lineNum">    1590 </span>            : ////////////////////////////// Logical operations ///////////////////////////////
<span class="lineNum">    1591 </span>            : 
<span class="lineNum">    1592 </span>            : static inline Mat&amp; operator &amp;= (const Mat&amp; a, const Mat&amp; b)
<span class="lineNum">    1593 </span>            : {
<span class="lineNum">    1594 </span>            :     bitwise_and(a, b, (Mat&amp;)a);
<span class="lineNum">    1595 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1596 </span>            : }
<span class="lineNum">    1597 </span>            : 
<span class="lineNum">    1598 </span>            : static inline Mat&amp; operator &amp;= (const Mat&amp; a, const Scalar&amp; s)
<span class="lineNum">    1599 </span>            : {
<span class="lineNum">    1600 </span>            :     bitwise_and(a, s, (Mat&amp;)a);
<span class="lineNum">    1601 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1602 </span>            : }
<span class="lineNum">    1603 </span>            : 
<span class="lineNum">    1604 </span>            : template&lt;typename _Tp&gt; static inline Mat_&lt;_Tp&gt;&amp;
<span class="lineNum">    1605 </span>            : operator &amp;= (const Mat_&lt;_Tp&gt;&amp; a, const Mat_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1606 </span>            : {
<span class="lineNum">    1607 </span>            :     bitwise_and(a, b, (Mat&amp;)a);
<span class="lineNum">    1608 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1609 </span>            : }
<span class="lineNum">    1610 </span>            : 
<span class="lineNum">    1611 </span>            : template&lt;typename _Tp&gt; static inline Mat_&lt;_Tp&gt;&amp;
<span class="lineNum">    1612 </span>            : operator &amp;= (const Mat_&lt;_Tp&gt;&amp; a, const Scalar&amp; s)
<span class="lineNum">    1613 </span>            : {
<span class="lineNum">    1614 </span>            :     bitwise_and(a, s, (Mat&amp;)a);
<span class="lineNum">    1615 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1616 </span>            : }
<span class="lineNum">    1617 </span>            : 
<span class="lineNum">    1618 </span>            : static inline Mat&amp; operator |= (const Mat&amp; a, const Mat&amp; b)
<span class="lineNum">    1619 </span>            : {
<span class="lineNum">    1620 </span>            :     bitwise_or(a, b, (Mat&amp;)a);
<span class="lineNum">    1621 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1622 </span>            : }
<span class="lineNum">    1623 </span>            : 
<span class="lineNum">    1624 </span>            : static inline Mat&amp; operator |= (const Mat&amp; a, const Scalar&amp; s)
<span class="lineNum">    1625 </span>            : {
<span class="lineNum">    1626 </span>            :     bitwise_or(a, s, (Mat&amp;)a);
<span class="lineNum">    1627 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1628 </span>            : }
<span class="lineNum">    1629 </span>            : 
<span class="lineNum">    1630 </span>            : template&lt;typename _Tp&gt; static inline Mat_&lt;_Tp&gt;&amp;
<span class="lineNum">    1631 </span>            : operator |= (const Mat_&lt;_Tp&gt;&amp; a, const Mat_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1632 </span>            : {
<span class="lineNum">    1633 </span>            :     bitwise_or(a, b, (Mat&amp;)a);
<span class="lineNum">    1634 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1635 </span>            : }
<span class="lineNum">    1636 </span>            : 
<span class="lineNum">    1637 </span>            : template&lt;typename _Tp&gt; static inline Mat_&lt;_Tp&gt;&amp;
<span class="lineNum">    1638 </span>            : operator |= (const Mat_&lt;_Tp&gt;&amp; a, const Scalar&amp; s)
<span class="lineNum">    1639 </span>            : {
<span class="lineNum">    1640 </span>            :     bitwise_or(a, s, (Mat&amp;)a);
<span class="lineNum">    1641 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1642 </span>            : }
<span class="lineNum">    1643 </span>            : 
<span class="lineNum">    1644 </span>            : static inline Mat&amp; operator ^= (const Mat&amp; a, const Mat&amp; b)
<span class="lineNum">    1645 </span>            : {
<span class="lineNum">    1646 </span>            :     bitwise_xor(a, b, (Mat&amp;)a);
<span class="lineNum">    1647 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1648 </span>            : }
<span class="lineNum">    1649 </span>            : 
<span class="lineNum">    1650 </span>            : static inline Mat&amp; operator ^= (const Mat&amp; a, const Scalar&amp; s)
<span class="lineNum">    1651 </span>            : {
<span class="lineNum">    1652 </span>            :     bitwise_xor(a, s, (Mat&amp;)a);
<span class="lineNum">    1653 </span>            :     return (Mat&amp;)a;
<span class="lineNum">    1654 </span>            : }
<span class="lineNum">    1655 </span>            : 
<span class="lineNum">    1656 </span>            : template&lt;typename _Tp&gt; static inline Mat_&lt;_Tp&gt;&amp;
<span class="lineNum">    1657 </span>            : operator ^= (const Mat_&lt;_Tp&gt;&amp; a, const Mat_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1658 </span>            : {
<span class="lineNum">    1659 </span>            :     bitwise_xor(a, b, (Mat&amp;)a);
<span class="lineNum">    1660 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1661 </span>            : }
<span class="lineNum">    1662 </span>            : 
<span class="lineNum">    1663 </span>            : template&lt;typename _Tp&gt; static inline Mat_&lt;_Tp&gt;&amp;
<span class="lineNum">    1664 </span>            : operator ^= (const Mat_&lt;_Tp&gt;&amp; a, const Scalar&amp; s)
<span class="lineNum">    1665 </span>            : {
<span class="lineNum">    1666 </span>            :     bitwise_xor(a, s, (Mat&amp;)a);
<span class="lineNum">    1667 </span>            :     return (Mat_&lt;_Tp&gt;&amp;)a;
<span class="lineNum">    1668 </span>            : }
<span class="lineNum">    1669 </span>            : 
<span class="lineNum">    1670 </span>            : /////////////////////////////// Miscellaneous operations //////////////////////////////
<span class="lineNum">    1671 </span>            : 
<span class="lineNum">    1672 </span>            : template&lt;typename _Tp&gt; void split(const Mat&amp; src, vector&lt;Mat_&lt;_Tp&gt; &gt;&amp; mv)
<span class="lineNum">    1673 </span>            : { split(src, (vector&lt;Mat&gt;&amp;)mv ); }
<span class="lineNum">    1674 </span>            : 
<span class="lineNum">    1675 </span>            : //////////////////////////////////////////////////////////////
<span class="lineNum">    1676 </span>            : 
<span class="lineNum">    1677 </span>            : template&lt;typename _Tp&gt; inline MatExpr Mat_&lt;_Tp&gt;::zeros(int rows, int cols)
<span class="lineNum">    1678 </span>            : {
<span class="lineNum">    1679 </span>            :     return Mat::zeros(rows, cols, DataType&lt;_Tp&gt;::type);
<span class="lineNum">    1680 </span>            : }
<span class="lineNum">    1681 </span>            : 
<span class="lineNum">    1682 </span>            : template&lt;typename _Tp&gt; inline MatExpr Mat_&lt;_Tp&gt;::zeros(Size sz)
<span class="lineNum">    1683 </span>            : {
<span class="lineNum">    1684 </span>            :     return Mat::zeros(sz, DataType&lt;_Tp&gt;::type);
<span class="lineNum">    1685 </span>            : }
<span class="lineNum">    1686 </span>            : 
<span class="lineNum">    1687 </span>            : template&lt;typename _Tp&gt; inline MatExpr Mat_&lt;_Tp&gt;::ones(int rows, int cols)
<span class="lineNum">    1688 </span>            : {
<span class="lineNum">    1689 </span>            :     return Mat::ones(rows, cols, DataType&lt;_Tp&gt;::type);
<span class="lineNum">    1690 </span>            : }
<span class="lineNum">    1691 </span>            : 
<span class="lineNum">    1692 </span>            : template&lt;typename _Tp&gt; inline MatExpr Mat_&lt;_Tp&gt;::ones(Size sz)
<span class="lineNum">    1693 </span>            : {
<span class="lineNum">    1694 </span>            :     return Mat::ones(sz, DataType&lt;_Tp&gt;::type);
<span class="lineNum">    1695 </span>            : }
<span class="lineNum">    1696 </span>            : 
<span class="lineNum">    1697 </span>            : template&lt;typename _Tp&gt; inline MatExpr Mat_&lt;_Tp&gt;::eye(int rows, int cols)
<span class="lineNum">    1698 </span>            : {
<span class="lineNum">    1699 </span>            :     return Mat::eye(rows, cols, DataType&lt;_Tp&gt;::type);
<span class="lineNum">    1700 </span>            : }
<span class="lineNum">    1701 </span>            : 
<span class="lineNum">    1702 </span>            : template&lt;typename _Tp&gt; inline MatExpr Mat_&lt;_Tp&gt;::eye(Size sz)
<span class="lineNum">    1703 </span>            : {
<span class="lineNum">    1704 </span>            :     return Mat::eye(sz, DataType&lt;_Tp&gt;::type);
<span class="lineNum">    1705 </span>            : }
<span class="lineNum">    1706 </span>            : 
<span class="lineNum">    1707 </span>            : //////////////////////////////// Iterators &amp; Comma initializers //////////////////////////////////
<span class="lineNum">    1708 </span>            : 
<span class="lineNum">    1709 </span>            : inline MatConstIterator::MatConstIterator()
<span class="lineNum">    1710 </span>            :     : m(0), elemSize(0), ptr(0), sliceStart(0), sliceEnd(0) {}
<span class="lineNum">    1711 </span>            : 
<span class="lineNum">    1712 </span>            : inline MatConstIterator::MatConstIterator(const Mat* _m)
<span class="lineNum">    1713 </span>            :     : m(_m), elemSize(_m-&gt;elemSize()), ptr(0), sliceStart(0), sliceEnd(0)
<span class="lineNum">    1714 </span>            : {
<span class="lineNum">    1715 </span>            :     if( m &amp;&amp; m-&gt;isContinuous() )
<span class="lineNum">    1716 </span>            :     {
<span class="lineNum">    1717 </span>            :         sliceStart = m-&gt;data;
<span class="lineNum">    1718 </span>            :         sliceEnd = sliceStart + m-&gt;total()*elemSize;
<span class="lineNum">    1719 </span>            :     }
<span class="lineNum">    1720 </span>            :     seek((const int*)0);
<span class="lineNum">    1721 </span>            : }
<span class="lineNum">    1722 </span>            : 
<span class="lineNum">    1723 </span>            : inline MatConstIterator::MatConstIterator(const Mat* _m, int _row, int _col)
<span class="lineNum">    1724 </span>            :     : m(_m), elemSize(_m-&gt;elemSize()), ptr(0), sliceStart(0), sliceEnd(0)
<span class="lineNum">    1725 </span>            : {
<span class="lineNum">    1726 </span>            :     CV_Assert(m &amp;&amp; m-&gt;dims &lt;= 2);
<span class="lineNum">    1727 </span>            :     if( m-&gt;isContinuous() )
<span class="lineNum">    1728 </span>            :     {
<span class="lineNum">    1729 </span>            :         sliceStart = m-&gt;data;
<span class="lineNum">    1730 </span>            :         sliceEnd = sliceStart + m-&gt;total()*elemSize;
<span class="lineNum">    1731 </span>            :     }
<span class="lineNum">    1732 </span>            :     int idx[]={_row, _col};
<span class="lineNum">    1733 </span>            :     seek(idx);
<span class="lineNum">    1734 </span>            : }
<span class="lineNum">    1735 </span>            : 
<span class="lineNum">    1736 </span>            : inline MatConstIterator::MatConstIterator(const Mat* _m, Point _pt)
<span class="lineNum">    1737 </span>            :     : m(_m), elemSize(_m-&gt;elemSize()), ptr(0), sliceStart(0), sliceEnd(0)
<span class="lineNum">    1738 </span>            : {
<span class="lineNum">    1739 </span>            :     CV_Assert(m &amp;&amp; m-&gt;dims &lt;= 2);
<span class="lineNum">    1740 </span>            :     if( m-&gt;isContinuous() )
<span class="lineNum">    1741 </span>            :     {
<span class="lineNum">    1742 </span>            :         sliceStart = m-&gt;data;
<span class="lineNum">    1743 </span>            :         sliceEnd = sliceStart + m-&gt;total()*elemSize;
<span class="lineNum">    1744 </span>            :     }
<span class="lineNum">    1745 </span>            :     int idx[]={_pt.y, _pt.x};
<span class="lineNum">    1746 </span>            :     seek(idx);
<span class="lineNum">    1747 </span>            : }
<span class="lineNum">    1748 </span>            : 
<span class="lineNum">    1749 </span>            : inline MatConstIterator::MatConstIterator(const MatConstIterator&amp; it)
<span class="lineNum">    1750 </span>            :     : m(it.m), elemSize(it.elemSize), ptr(it.ptr), sliceStart(it.sliceStart), sliceEnd(it.sliceEnd)
<span class="lineNum">    1751 </span>            : {}
<span class="lineNum">    1752 </span>            : 
<span class="lineNum">    1753 </span>            : inline MatConstIterator&amp; MatConstIterator::operator = (const MatConstIterator&amp; it )
<span class="lineNum">    1754 </span>            : {
<span class="lineNum">    1755 </span>            :     m = it.m; elemSize = it.elemSize; ptr = it.ptr;
<span class="lineNum">    1756 </span>            :     sliceStart = it.sliceStart; sliceEnd = it.sliceEnd;
<span class="lineNum">    1757 </span>            :     return *this;
<span class="lineNum">    1758 </span>            : }
<span class="lineNum">    1759 </span>            : 
<span class="lineNum">    1760 </span>            : inline uchar* MatConstIterator::operator *() const { return ptr; }
<span class="lineNum">    1761 </span>            : 
<span class="lineNum">    1762 </span>            : inline MatConstIterator&amp; MatConstIterator::operator += (ptrdiff_t ofs)
<span class="lineNum">    1763 </span>            : {
<span class="lineNum">    1764 </span>            :     if( !m || ofs == 0 )
<span class="lineNum">    1765 </span>            :         return *this;
<span class="lineNum">    1766 </span>            :     ptrdiff_t ofsb = ofs*elemSize;
<span class="lineNum">    1767 </span>            :     ptr += ofsb;
<span class="lineNum">    1768 </span>            :     if( ptr &lt; sliceStart || sliceEnd &lt;= ptr )
<span class="lineNum">    1769 </span>            :     {
<span class="lineNum">    1770 </span>            :         ptr -= ofsb;
<span class="lineNum">    1771 </span>            :         seek(ofs, true);
<span class="lineNum">    1772 </span>            :     }
<span class="lineNum">    1773 </span>            :     return *this;
<span class="lineNum">    1774 </span>            : }
<span class="lineNum">    1775 </span>            : 
<span class="lineNum">    1776 </span>            : inline MatConstIterator&amp; MatConstIterator::operator -= (ptrdiff_t ofs)
<span class="lineNum">    1777 </span>            : { return (*this += -ofs); }
<span class="lineNum">    1778 </span>            : 
<span class="lineNum">    1779 </span>            : inline MatConstIterator&amp; MatConstIterator::operator --()
<span class="lineNum">    1780 </span>            : {
<span class="lineNum">    1781 </span>            :     if( m &amp;&amp; (ptr -= elemSize) &lt; sliceStart )
<span class="lineNum">    1782 </span>            :     {
<span class="lineNum">    1783 </span>            :         ptr += elemSize;
<span class="lineNum">    1784 </span>            :         seek(-1, true);
<span class="lineNum">    1785 </span>            :     }
<span class="lineNum">    1786 </span>            :     return *this;
<span class="lineNum">    1787 </span>            : }
<span class="lineNum">    1788 </span>            : 
<span class="lineNum">    1789 </span>            : inline MatConstIterator MatConstIterator::operator --(int)
<span class="lineNum">    1790 </span>            : {
<span class="lineNum">    1791 </span>            :     MatConstIterator b = *this;
<span class="lineNum">    1792 </span>            :     *this += -1;
<span class="lineNum">    1793 </span>            :     return b;
<span class="lineNum">    1794 </span>            : }
<span class="lineNum">    1795 </span>            : 
<span class="lineNum">    1796 </span>            : inline MatConstIterator&amp; MatConstIterator::operator ++()
<span class="lineNum">    1797 </span>            : {
<span class="lineNum">    1798 </span>            :     if( m &amp;&amp; (ptr += elemSize) &gt;= sliceEnd )
<span class="lineNum">    1799 </span>            :     {
<span class="lineNum">    1800 </span>            :         ptr -= elemSize;
<span class="lineNum">    1801 </span>            :         seek(1, true);
<span class="lineNum">    1802 </span>            :     }
<span class="lineNum">    1803 </span>            :     return *this;
<span class="lineNum">    1804 </span>            : }
<span class="lineNum">    1805 </span>            : 
<span class="lineNum">    1806 </span>            : inline MatConstIterator MatConstIterator::operator ++(int)
<span class="lineNum">    1807 </span>            : {
<span class="lineNum">    1808 </span>            :     MatConstIterator b = *this;
<span class="lineNum">    1809 </span>            :     *this += 1;
<span class="lineNum">    1810 </span>            :     return b;
<span class="lineNum">    1811 </span>            : }
<span class="lineNum">    1812 </span>            : 
<span class="lineNum">    1813 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt;::MatConstIterator_() {}
<span class="lineNum">    1814 </span>            : 
<span class="lineNum">    1815 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt;::MatConstIterator_(const Mat_&lt;_Tp&gt;* _m)
<span class="lineNum">    1816 </span>            :     : MatConstIterator(_m) {}
<span class="lineNum">    1817 </span>            : 
<span class="lineNum">    1818 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt;::
<span class="lineNum">    1819 </span>            :     MatConstIterator_(const Mat_&lt;_Tp&gt;* _m, int _row, int _col)
<span class="lineNum">    1820 </span>            :     : MatConstIterator(_m, _row, _col) {}
<span class="lineNum">    1821 </span>            : 
<span class="lineNum">    1822 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt;::
<span class="lineNum">    1823 </span>            :     MatConstIterator_(const Mat_&lt;_Tp&gt;* _m, Point _pt)
<span class="lineNum">    1824 </span>            :     : MatConstIterator(_m, _pt) {}
<span class="lineNum">    1825 </span>            : 
<span class="lineNum">    1826 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt;::
<span class="lineNum">    1827 </span>            :     MatConstIterator_(const MatConstIterator_&amp; it)
<span class="lineNum">    1828 </span>            :     : MatConstIterator(it) {}
<span class="lineNum">    1829 </span>            : 
<span class="lineNum">    1830 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt;&amp;
<span class="lineNum">    1831 </span>            :     MatConstIterator_&lt;_Tp&gt;::operator = (const MatConstIterator_&amp; it )
<span class="lineNum">    1832 </span>            : {
<span class="lineNum">    1833 </span>            :     MatConstIterator::operator = (it);
<span class="lineNum">    1834 </span>            :     return *this;
<span class="lineNum">    1835 </span>            : }
<span class="lineNum">    1836 </span>            : 
<span class="lineNum">    1837 </span>            : template&lt;typename _Tp&gt; inline _Tp MatConstIterator_&lt;_Tp&gt;::operator *() const { return *(_Tp*)(this-&gt;ptr); }
<span class="lineNum">    1838 </span>            : 
<span class="lineNum">    1839 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt;&amp; MatConstIterator_&lt;_Tp&gt;::operator += (ptrdiff_t ofs)
<span class="lineNum">    1840 </span>            : {
<span class="lineNum">    1841 </span>            :     MatConstIterator::operator += (ofs);
<span class="lineNum">    1842 </span>            :     return *this;
<span class="lineNum">    1843 </span>            : }
<span class="lineNum">    1844 </span>            : 
<span class="lineNum">    1845 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt;&amp; MatConstIterator_&lt;_Tp&gt;::operator -= (ptrdiff_t ofs)
<span class="lineNum">    1846 </span>            : { return (*this += -ofs); }
<span class="lineNum">    1847 </span>            : 
<span class="lineNum">    1848 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt;&amp; MatConstIterator_&lt;_Tp&gt;::operator --()
<span class="lineNum">    1849 </span>            : {
<span class="lineNum">    1850 </span>            :     MatConstIterator::operator --();
<span class="lineNum">    1851 </span>            :     return *this;
<span class="lineNum">    1852 </span>            : }
<span class="lineNum">    1853 </span>            : 
<span class="lineNum">    1854 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt; MatConstIterator_&lt;_Tp&gt;::operator --(int)
<span class="lineNum">    1855 </span>            : {
<span class="lineNum">    1856 </span>            :     MatConstIterator_ b = *this;
<span class="lineNum">    1857 </span>            :     MatConstIterator::operator --();
<span class="lineNum">    1858 </span>            :     return b;
<span class="lineNum">    1859 </span>            : }
<span class="lineNum">    1860 </span>            : 
<span class="lineNum">    1861 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt;&amp; MatConstIterator_&lt;_Tp&gt;::operator ++()
<span class="lineNum">    1862 </span>            : {
<span class="lineNum">    1863 </span>            :     MatConstIterator::operator ++();
<span class="lineNum">    1864 </span>            :     return *this;
<span class="lineNum">    1865 </span>            : }
<span class="lineNum">    1866 </span>            : 
<span class="lineNum">    1867 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt; MatConstIterator_&lt;_Tp&gt;::operator ++(int)
<span class="lineNum">    1868 </span>            : {
<span class="lineNum">    1869 </span>            :     MatConstIterator_ b = *this;
<span class="lineNum">    1870 </span>            :     MatConstIterator::operator ++();
<span class="lineNum">    1871 </span>            :     return b;
<span class="lineNum">    1872 </span>            : }
<span class="lineNum">    1873 </span>            : 
<span class="lineNum">    1874 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt;::MatIterator_() : MatConstIterator_&lt;_Tp&gt;() {}
<span class="lineNum">    1875 </span>            : 
<span class="lineNum">    1876 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt;::MatIterator_(Mat_&lt;_Tp&gt;* _m)
<span class="lineNum">    1877 </span>            :     : MatConstIterator_&lt;_Tp&gt;(_m) {}
<span class="lineNum">    1878 </span>            : 
<span class="lineNum">    1879 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt;::MatIterator_(Mat_&lt;_Tp&gt;* _m, int _row, int _col)
<span class="lineNum">    1880 </span>            :     : MatConstIterator_&lt;_Tp&gt;(_m, _row, _col) {}
<span class="lineNum">    1881 </span>            : 
<span class="lineNum">    1882 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt;::MatIterator_(const Mat_&lt;_Tp&gt;* _m, Point _pt)
<span class="lineNum">    1883 </span>            :     : MatConstIterator_&lt;_Tp&gt;(_m, _pt) {}
<span class="lineNum">    1884 </span>            : 
<span class="lineNum">    1885 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt;::MatIterator_(const Mat_&lt;_Tp&gt;* _m, const int* _idx)
<span class="lineNum">    1886 </span>            :     : MatConstIterator_&lt;_Tp&gt;(_m, _idx) {}
<span class="lineNum">    1887 </span>            : 
<span class="lineNum">    1888 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt;::MatIterator_(const MatIterator_&amp; it)
<span class="lineNum">    1889 </span>            :     : MatConstIterator_&lt;_Tp&gt;(it) {}
<span class="lineNum">    1890 </span>            : 
<span class="lineNum">    1891 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt;&amp; MatIterator_&lt;_Tp&gt;::operator = (const MatIterator_&lt;_Tp&gt;&amp; it )
<span class="lineNum">    1892 </span>            : {
<span class="lineNum">    1893 </span>            :     MatConstIterator::operator = (it);
<span class="lineNum">    1894 </span>            :     return *this;
<span class="lineNum">    1895 </span>            : }
<span class="lineNum">    1896 </span>            : 
<span class="lineNum">    1897 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; MatIterator_&lt;_Tp&gt;::operator *() const { return *(_Tp*)(this-&gt;ptr); }
<span class="lineNum">    1898 </span>            : 
<span class="lineNum">    1899 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt;&amp; MatIterator_&lt;_Tp&gt;::operator += (ptrdiff_t ofs)
<span class="lineNum">    1900 </span>            : {
<span class="lineNum">    1901 </span>            :     MatConstIterator::operator += (ofs);
<span class="lineNum">    1902 </span>            :     return *this;
<span class="lineNum">    1903 </span>            : }
<span class="lineNum">    1904 </span>            : 
<span class="lineNum">    1905 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt;&amp; MatIterator_&lt;_Tp&gt;::operator -= (ptrdiff_t ofs)
<span class="lineNum">    1906 </span>            : {
<span class="lineNum">    1907 </span>            :     MatConstIterator::operator += (-ofs);
<span class="lineNum">    1908 </span>            :     return *this;
<span class="lineNum">    1909 </span>            : }
<span class="lineNum">    1910 </span>            : 
<span class="lineNum">    1911 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt;&amp; MatIterator_&lt;_Tp&gt;::operator --()
<span class="lineNum">    1912 </span>            : {
<span class="lineNum">    1913 </span>            :     MatConstIterator::operator --();
<span class="lineNum">    1914 </span>            :     return *this;
<span class="lineNum">    1915 </span>            : }
<span class="lineNum">    1916 </span>            : 
<span class="lineNum">    1917 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt; MatIterator_&lt;_Tp&gt;::operator --(int)
<span class="lineNum">    1918 </span>            : {
<span class="lineNum">    1919 </span>            :     MatIterator_ b = *this;
<span class="lineNum">    1920 </span>            :     MatConstIterator::operator --();
<span class="lineNum">    1921 </span>            :     return b;
<span class="lineNum">    1922 </span>            : }
<span class="lineNum">    1923 </span>            : 
<span class="lineNum">    1924 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt;&amp; MatIterator_&lt;_Tp&gt;::operator ++()
<span class="lineNum">    1925 </span>            : {
<span class="lineNum">    1926 </span>            :     MatConstIterator::operator ++();
<span class="lineNum">    1927 </span>            :     return *this;
<span class="lineNum">    1928 </span>            : }
<span class="lineNum">    1929 </span>            : 
<span class="lineNum">    1930 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt; MatIterator_&lt;_Tp&gt;::operator ++(int)
<span class="lineNum">    1931 </span>            : {
<span class="lineNum">    1932 </span>            :     MatIterator_ b = *this;
<span class="lineNum">    1933 </span>            :     MatConstIterator::operator ++();
<span class="lineNum">    1934 </span>            :     return b;
<span class="lineNum">    1935 </span>            : }
<span class="lineNum">    1936 </span>            : 
<span class="lineNum">    1937 </span>            : template&lt;typename _Tp&gt; inline Point MatConstIterator_&lt;_Tp&gt;::pos() const
<span class="lineNum">    1938 </span>            : {
<span class="lineNum">    1939 </span>            :     if( !m )
<span class="lineNum">    1940 </span>            :         return Point();
<span class="lineNum">    1941 </span>            :     CV_DbgAssert( m-&gt;dims &lt;= 2 );
<span class="lineNum">    1942 </span>            :     if( m-&gt;isContinuous() )
<span class="lineNum">    1943 </span>            :     {
<span class="lineNum">    1944 </span>            :         ptrdiff_t ofs = (const _Tp*)ptr - (const _Tp*)m-&gt;data;
<span class="lineNum">    1945 </span>            :         int y = (int)(ofs / m-&gt;cols), x = (int)(ofs - (ptrdiff_t)y*m-&gt;cols);
<span class="lineNum">    1946 </span>            :         return Point(x, y);
<span class="lineNum">    1947 </span>            :     }
<span class="lineNum">    1948 </span>            :     else
<span class="lineNum">    1949 </span>            :     {
<span class="lineNum">    1950 </span>            :         ptrdiff_t ofs = (uchar*)ptr - m-&gt;data;
<span class="lineNum">    1951 </span>            :         int y = (int)(ofs / m-&gt;step), x = (int)((ofs - y*m-&gt;step)/sizeof(_Tp));
<span class="lineNum">    1952 </span>            :         return Point(x, y);
<span class="lineNum">    1953 </span>            :     }
<span class="lineNum">    1954 </span>            : }
<span class="lineNum">    1955 </span>            : 
<span class="lineNum">    1956 </span>            : static inline bool
<span class="lineNum">    1957 </span>            : operator == (const MatConstIterator&amp; a, const MatConstIterator&amp; b)
<span class="lineNum">    1958 </span>            : { return a.m == b.m &amp;&amp; a.ptr == b.ptr; }
<span class="lineNum">    1959 </span>            : 
<span class="lineNum">    1960 </span>            : template&lt;typename _Tp&gt; static inline bool
<span class="lineNum">    1961 </span>            : operator != (const MatConstIterator&amp; a, const MatConstIterator&amp; b)
<span class="lineNum">    1962 </span>            : { return !(a == b); }
<span class="lineNum">    1963 </span>            : 
<span class="lineNum">    1964 </span>            : template&lt;typename _Tp&gt; static inline bool
<span class="lineNum">    1965 </span>            : operator == (const MatConstIterator_&lt;_Tp&gt;&amp; a, const MatConstIterator_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1966 </span>            : { return a.m == b.m &amp;&amp; a.ptr == b.ptr; }
<span class="lineNum">    1967 </span>            : 
<span class="lineNum">    1968 </span>            : template&lt;typename _Tp&gt; static inline bool
<span class="lineNum">    1969 </span>            : operator != (const MatConstIterator_&lt;_Tp&gt;&amp; a, const MatConstIterator_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1970 </span>            : { return a.m != b.m || a.ptr != b.ptr; }
<span class="lineNum">    1971 </span>            : 
<span class="lineNum">    1972 </span>            : template&lt;typename _Tp&gt; static inline bool
<span class="lineNum">    1973 </span>            : operator == (const MatIterator_&lt;_Tp&gt;&amp; a, const MatIterator_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1974 </span>            : { return a.m == b.m &amp;&amp; a.ptr == b.ptr; }
<span class="lineNum">    1975 </span>            : 
<span class="lineNum">    1976 </span>            : template&lt;typename _Tp&gt; static inline bool
<span class="lineNum">    1977 </span>            : operator != (const MatIterator_&lt;_Tp&gt;&amp; a, const MatIterator_&lt;_Tp&gt;&amp; b)
<span class="lineNum">    1978 </span>            : { return a.m != b.m || a.ptr != b.ptr; }
<span class="lineNum">    1979 </span>            : 
<span class="lineNum">    1980 </span>            : static inline bool
<span class="lineNum">    1981 </span>            : operator &lt; (const MatConstIterator&amp; a, const MatConstIterator&amp; b)
<span class="lineNum">    1982 </span>            : { return a.ptr &lt; b.ptr; }
<span class="lineNum">    1983 </span>            : 
<span class="lineNum">    1984 </span>            : static inline bool
<span class="lineNum">    1985 </span>            : operator &gt; (const MatConstIterator&amp; a, const MatConstIterator&amp; b)
<span class="lineNum">    1986 </span>            : { return a.ptr &gt; b.ptr; }
<span class="lineNum">    1987 </span>            : 
<span class="lineNum">    1988 </span>            : static inline bool
<span class="lineNum">    1989 </span>            : operator &lt;= (const MatConstIterator&amp; a, const MatConstIterator&amp; b)
<span class="lineNum">    1990 </span>            : { return a.ptr &lt;= b.ptr; }
<span class="lineNum">    1991 </span>            : 
<span class="lineNum">    1992 </span>            : static inline bool
<span class="lineNum">    1993 </span>            : operator &gt;= (const MatConstIterator&amp; a, const MatConstIterator&amp; b)
<span class="lineNum">    1994 </span>            : { return a.ptr &gt;= b.ptr; }
<span class="lineNum">    1995 </span>            : 
<span class="lineNum">    1996 </span>            : CV_EXPORTS ptrdiff_t operator - (const MatConstIterator&amp; b, const MatConstIterator&amp; a);
<span class="lineNum">    1997 </span>            : 
<span class="lineNum">    1998 </span>            : static inline MatConstIterator operator + (const MatConstIterator&amp; a, ptrdiff_t ofs)
<span class="lineNum">    1999 </span>            : { MatConstIterator b = a; return b += ofs; }
<span class="lineNum">    2000 </span>            : 
<span class="lineNum">    2001 </span>            : static inline MatConstIterator operator + (ptrdiff_t ofs, const MatConstIterator&amp; a)
<span class="lineNum">    2002 </span>            : { MatConstIterator b = a; return b += ofs; }
<span class="lineNum">    2003 </span>            : 
<span class="lineNum">    2004 </span>            : static inline MatConstIterator operator - (const MatConstIterator&amp; a, ptrdiff_t ofs)
<span class="lineNum">    2005 </span>            : { MatConstIterator b = a; return b += -ofs; }
<span class="lineNum">    2006 </span>            : 
<span class="lineNum">    2007 </span>            : template&lt;typename _Tp&gt; static inline MatConstIterator_&lt;_Tp&gt;
<span class="lineNum">    2008 </span>            : operator + (const MatConstIterator_&lt;_Tp&gt;&amp; a, ptrdiff_t ofs)
<span class="lineNum">    2009 </span>            : { MatConstIterator t = (const MatConstIterator&amp;)a + ofs; return (MatConstIterator_&lt;_Tp&gt;&amp;)t; }
<span class="lineNum">    2010 </span>            : 
<span class="lineNum">    2011 </span>            : template&lt;typename _Tp&gt; static inline MatConstIterator_&lt;_Tp&gt;
<span class="lineNum">    2012 </span>            : operator + (ptrdiff_t ofs, const MatConstIterator_&lt;_Tp&gt;&amp; a)
<span class="lineNum">    2013 </span>            : { MatConstIterator t = (const MatConstIterator&amp;)a + ofs; return (MatConstIterator_&lt;_Tp&gt;&amp;)t; }
<span class="lineNum">    2014 </span>            : 
<span class="lineNum">    2015 </span>            : template&lt;typename _Tp&gt; static inline MatConstIterator_&lt;_Tp&gt;
<span class="lineNum">    2016 </span>            : operator - (const MatConstIterator_&lt;_Tp&gt;&amp; a, ptrdiff_t ofs)
<span class="lineNum">    2017 </span>            : { MatConstIterator t = (const MatConstIterator&amp;)a - ofs; return (MatConstIterator_&lt;_Tp&gt;&amp;)t; }
<span class="lineNum">    2018 </span>            : 
<span class="lineNum">    2019 </span>            : inline uchar* MatConstIterator::operator [](ptrdiff_t i) const
<span class="lineNum">    2020 </span>            : { return *(*this + i); }
<span class="lineNum">    2021 </span>            : 
<span class="lineNum">    2022 </span>            : template&lt;typename _Tp&gt; inline _Tp MatConstIterator_&lt;_Tp&gt;::operator [](ptrdiff_t i) const
<span class="lineNum">    2023 </span>            : { return *(_Tp*)MatConstIterator::operator [](i); }
<span class="lineNum">    2024 </span>            : 
<span class="lineNum">    2025 </span>            : template&lt;typename _Tp&gt; static inline MatIterator_&lt;_Tp&gt;
<span class="lineNum">    2026 </span>            : operator + (const MatIterator_&lt;_Tp&gt;&amp; a, ptrdiff_t ofs)
<span class="lineNum">    2027 </span>            : { MatConstIterator t = (const MatConstIterator&amp;)a + ofs; return (MatIterator_&lt;_Tp&gt;&amp;)t; }
<span class="lineNum">    2028 </span>            : 
<span class="lineNum">    2029 </span>            : template&lt;typename _Tp&gt; static inline MatIterator_&lt;_Tp&gt;
<span class="lineNum">    2030 </span>            : operator + (ptrdiff_t ofs, const MatIterator_&lt;_Tp&gt;&amp; a)
<span class="lineNum">    2031 </span>            : { MatConstIterator t = (const MatConstIterator&amp;)a + ofs; return (MatIterator_&lt;_Tp&gt;&amp;)t; }
<span class="lineNum">    2032 </span>            : 
<span class="lineNum">    2033 </span>            : template&lt;typename _Tp&gt; static inline MatIterator_&lt;_Tp&gt;
<span class="lineNum">    2034 </span>            : operator - (const MatIterator_&lt;_Tp&gt;&amp; a, ptrdiff_t ofs)
<span class="lineNum">    2035 </span>            : { MatConstIterator t = (const MatConstIterator&amp;)a - ofs; return (MatIterator_&lt;_Tp&gt;&amp;)t; }
<span class="lineNum">    2036 </span>            : 
<span class="lineNum">    2037 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; MatIterator_&lt;_Tp&gt;::operator [](ptrdiff_t i) const
<span class="lineNum">    2038 </span>            : { return *(*this + i); }
<span class="lineNum">    2039 </span>            : 
<span class="lineNum">    2040 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt; Mat_&lt;_Tp&gt;::begin() const
<span class="lineNum">    2041 </span>            : { return Mat::begin&lt;_Tp&gt;(); }
<span class="lineNum">    2042 </span>            : 
<span class="lineNum">    2043 </span>            : template&lt;typename _Tp&gt; inline MatConstIterator_&lt;_Tp&gt; Mat_&lt;_Tp&gt;::end() const
<span class="lineNum">    2044 </span>            : { return Mat::end&lt;_Tp&gt;(); }
<span class="lineNum">    2045 </span>            : 
<span class="lineNum">    2046 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt; Mat_&lt;_Tp&gt;::begin()
<span class="lineNum">    2047 </span>            : { return Mat::begin&lt;_Tp&gt;(); }
<span class="lineNum">    2048 </span>            : 
<span class="lineNum">    2049 </span>            : template&lt;typename _Tp&gt; inline MatIterator_&lt;_Tp&gt; Mat_&lt;_Tp&gt;::end()
<span class="lineNum">    2050 </span>            : { return Mat::end&lt;_Tp&gt;(); }
<span class="lineNum">    2051 </span>            : 
<span class="lineNum">    2052 </span>            : template&lt;typename _Tp&gt; inline MatCommaInitializer_&lt;_Tp&gt;::MatCommaInitializer_(Mat_&lt;_Tp&gt;* _m) : it(_m) {}
<span class="lineNum">    2053 </span>            : 
<span class="lineNum">    2054 </span>            : template&lt;typename _Tp&gt; template&lt;typename T2&gt; inline MatCommaInitializer_&lt;_Tp&gt;&amp;
<span class="lineNum">    2055 </span>            : MatCommaInitializer_&lt;_Tp&gt;::operator , (T2 v)
<span class="lineNum">    2056 </span>            : {
<span class="lineNum">    2057 </span>            :     CV_DbgAssert( this-&gt;it &lt; ((const Mat_&lt;_Tp&gt;*)this-&gt;it.m)-&gt;end() );
<span class="lineNum">    2058 </span>            :     *this-&gt;it = _Tp(v); ++this-&gt;it;
<span class="lineNum">    2059 </span>            :     return *this;
<span class="lineNum">    2060 </span>            : }
<span class="lineNum">    2061 </span>            : 
<span class="lineNum">    2062 </span>            : template&lt;typename _Tp&gt; inline Mat_&lt;_Tp&gt; MatCommaInitializer_&lt;_Tp&gt;::operator *() const
<span class="lineNum">    2063 </span>            : {
<span class="lineNum">    2064 </span>            :     CV_DbgAssert( this-&gt;it == ((const Mat_&lt;_Tp&gt;*)this-&gt;it.m)-&gt;end() );
<span class="lineNum">    2065 </span>            :     return Mat_&lt;_Tp&gt;(*this-&gt;it.m);
<span class="lineNum">    2066 </span>            : }
<span class="lineNum">    2067 </span>            : 
<span class="lineNum">    2068 </span>            : template&lt;typename _Tp&gt; inline MatCommaInitializer_&lt;_Tp&gt;::operator Mat_&lt;_Tp&gt;() const
<span class="lineNum">    2069 </span>            : {
<span class="lineNum">    2070 </span>            :     CV_DbgAssert( this-&gt;it == ((const Mat_&lt;_Tp&gt;*)this-&gt;it.m)-&gt;end() );
<span class="lineNum">    2071 </span>            :     return Mat_&lt;_Tp&gt;(*this-&gt;it.m);
<span class="lineNum">    2072 </span>            : }
<span class="lineNum">    2073 </span>            : 
<span class="lineNum">    2074 </span>            : template&lt;typename _Tp, typename T2&gt; static inline MatCommaInitializer_&lt;_Tp&gt;
<span class="lineNum">    2075 </span>            : operator &lt;&lt; (const Mat_&lt;_Tp&gt;&amp; m, T2 val)
<span class="lineNum">    2076 </span>            : {
<span class="lineNum">    2077 </span>            :     MatCommaInitializer_&lt;_Tp&gt; commaInitializer((Mat_&lt;_Tp&gt;*)&amp;m);
<span class="lineNum">    2078 </span>            :     return (commaInitializer, val);
<span class="lineNum">    2079 </span>            : }
<span class="lineNum">    2080 </span>            : 
<span class="lineNum">    2081 </span>            : //////////////////////////////// SparseMat ////////////////////////////////
<span class="lineNum">    2082 </span>            : 
<span class="lineNum">    2083 </span>            : inline SparseMat::SparseMat()
<span class="lineNum">    2084 </span>            : : flags(MAGIC_VAL), hdr(0)
<span class="lineNum">    2085 </span>            : {
<span class="lineNum">    2086 </span>            : }
<span class="lineNum">    2087 </span>            : 
<span class="lineNum">    2088 </span>            : inline SparseMat::SparseMat(int _dims, const int* _sizes, int _type)
<span class="lineNum">    2089 </span>            : : flags(MAGIC_VAL), hdr(0)
<span class="lineNum">    2090 </span>            : {
<span class="lineNum">    2091 </span>            :     create(_dims, _sizes, _type);
<span class="lineNum">    2092 </span>            : }
<span class="lineNum">    2093 </span>            : 
<span class="lineNum">    2094 </span>            : inline SparseMat::SparseMat(const SparseMat&amp; m)
<span class="lineNum">    2095 </span>            : : flags(m.flags), hdr(m.hdr)
<span class="lineNum">    2096 </span>            : {
<span class="lineNum">    2097 </span>            :     addref();
<span class="lineNum">    2098 </span>            : }
<span class="lineNum">    2099 </span>            : 
<span class="lineNum">    2100 </span>            : inline SparseMat::~SparseMat()
<span class="lineNum">    2101 </span>            : {
<span class="lineNum">    2102 </span>            :     release();
<span class="lineNum">    2103 </span>            : }
<span class="lineNum">    2104 </span>            : 
<span class="lineNum">    2105 </span>            : inline SparseMat&amp; SparseMat::operator = (const SparseMat&amp; m)
<span class="lineNum">    2106 </span>            : {
<span class="lineNum">    2107 </span>            :     if( this != &amp;m )
<span class="lineNum">    2108 </span>            :     {
<span class="lineNum">    2109 </span>            :         if( m.hdr )
<span class="lineNum">    2110 </span>            :             CV_XADD(&amp;m.hdr-&gt;refcount, 1);
<span class="lineNum">    2111 </span>            :         release();
<span class="lineNum">    2112 </span>            :         flags = m.flags;
<span class="lineNum">    2113 </span>            :         hdr = m.hdr;
<span class="lineNum">    2114 </span>            :     }
<span class="lineNum">    2115 </span>            :     return *this;
<span class="lineNum">    2116 </span>            : }
<span class="lineNum">    2117 </span>            : 
<span class="lineNum">    2118 </span>            : inline SparseMat&amp; SparseMat::operator = (const Mat&amp; m)
<span class="lineNum">    2119 </span>            : { return (*this = SparseMat(m)); }
<span class="lineNum">    2120 </span>            : 
<span class="lineNum">    2121 </span>            : inline SparseMat SparseMat::clone() const
<span class="lineNum">    2122 </span>            : {
<span class="lineNum">    2123 </span>            :     SparseMat temp;
<span class="lineNum">    2124 </span>            :     this-&gt;copyTo(temp);
<span class="lineNum">    2125 </span>            :     return temp;
<span class="lineNum">    2126 </span>            : }
<span class="lineNum">    2127 </span>            : 
<span class="lineNum">    2128 </span>            : 
<span class="lineNum">    2129 </span>            : inline void SparseMat::assignTo( SparseMat&amp; m, int _type ) const
<span class="lineNum">    2130 </span>            : {
<span class="lineNum">    2131 </span>            :     if( _type &lt; 0 )
<span class="lineNum">    2132 </span>            :         m = *this;
<span class="lineNum">    2133 </span>            :     else
<span class="lineNum">    2134 </span>            :         convertTo(m, _type);
<span class="lineNum">    2135 </span>            : }
<span class="lineNum">    2136 </span>            : 
<span class="lineNum">    2137 </span>            : inline void SparseMat::addref()
<span class="lineNum">    2138 </span>            : { if( hdr ) CV_XADD(&amp;hdr-&gt;refcount, 1); }
<span class="lineNum">    2139 </span>            : 
<span class="lineNum">    2140 </span>            : inline void SparseMat::release()
<span class="lineNum">    2141 </span>            : {
<span class="lineNum">    2142 </span>            :     if( hdr &amp;&amp; CV_XADD(&amp;hdr-&gt;refcount, -1) == 1 )
<span class="lineNum">    2143 </span>            :         delete hdr;
<span class="lineNum">    2144 </span>            :     hdr = 0;
<span class="lineNum">    2145 </span>            : }
<span class="lineNum">    2146 </span>            : 
<span class="lineNum">    2147 </span>            : inline size_t SparseMat::elemSize() const
<span class="lineNum">    2148 </span>            : { return CV_ELEM_SIZE(flags); }
<span class="lineNum">    2149 </span>            : 
<span class="lineNum">    2150 </span>            : inline size_t SparseMat::elemSize1() const
<span class="lineNum">    2151 </span>            : { return CV_ELEM_SIZE1(flags); }
<span class="lineNum">    2152 </span>            : 
<span class="lineNum">    2153 </span>            : inline int SparseMat::type() const
<span class="lineNum">    2154 </span>            : { return CV_MAT_TYPE(flags); }
<span class="lineNum">    2155 </span>            : 
<span class="lineNum">    2156 </span>            : inline int SparseMat::depth() const
<span class="lineNum">    2157 </span>            : { return CV_MAT_DEPTH(flags); }
<span class="lineNum">    2158 </span>            : 
<span class="lineNum">    2159 </span>            : inline int SparseMat::channels() const
<span class="lineNum">    2160 </span>            : { return CV_MAT_CN(flags); }
<span class="lineNum">    2161 </span>            : 
<span class="lineNum">    2162 </span>            : inline const int* SparseMat::size() const
<span class="lineNum">    2163 </span>            : {
<span class="lineNum">    2164 </span>            :     return hdr ? hdr-&gt;size : 0;
<span class="lineNum">    2165 </span>            : }
<span class="lineNum">    2166 </span>            : 
<span class="lineNum">    2167 </span>            : inline int SparseMat::size(int i) const
<span class="lineNum">    2168 </span>            : {
<span class="lineNum">    2169 </span>            :     if( hdr )
<span class="lineNum">    2170 </span>            :     {
<span class="lineNum">    2171 </span>            :         CV_DbgAssert((unsigned)i &lt; (unsigned)hdr-&gt;dims);
<span class="lineNum">    2172 </span>            :         return hdr-&gt;size[i];
<span class="lineNum">    2173 </span>            :     }
<span class="lineNum">    2174 </span>            :     return 0;
<span class="lineNum">    2175 </span>            : }
<span class="lineNum">    2176 </span>            : 
<span class="lineNum">    2177 </span>            : inline int SparseMat::dims() const
<span class="lineNum">    2178 </span>            : {
<span class="lineNum">    2179 </span>            :     return hdr ? hdr-&gt;dims : 0;
<span class="lineNum">    2180 </span>            : }
<span class="lineNum">    2181 </span>            : 
<span class="lineNum">    2182 </span>            : inline size_t SparseMat::nzcount() const
<span class="lineNum">    2183 </span>            : {
<span class="lineNum">    2184 </span>            :     return hdr ? hdr-&gt;nodeCount : 0;
<span class="lineNum">    2185 </span>            : }
<span class="lineNum">    2186 </span>            : 
<span class="lineNum">    2187 </span>            : inline size_t SparseMat::hash(int i0) const
<span class="lineNum">    2188 </span>            : {
<span class="lineNum">    2189 </span>            :     return (size_t)i0;
<span class="lineNum">    2190 </span>            : }
<span class="lineNum">    2191 </span>            : 
<span class="lineNum">    2192 </span>            : inline size_t SparseMat::hash(int i0, int i1) const
<span class="lineNum">    2193 </span>            : {
<span class="lineNum">    2194 </span>            :     return (size_t)(unsigned)i0*HASH_SCALE + (unsigned)i1;
<span class="lineNum">    2195 </span>            : }
<span class="lineNum">    2196 </span>            : 
<span class="lineNum">    2197 </span>            : inline size_t SparseMat::hash(int i0, int i1, int i2) const
<span class="lineNum">    2198 </span>            : {
<span class="lineNum">    2199 </span>            :     return ((size_t)(unsigned)i0*HASH_SCALE + (unsigned)i1)*HASH_SCALE + (unsigned)i2;
<span class="lineNum">    2200 </span>            : }
<span class="lineNum">    2201 </span>            : 
<span class="lineNum">    2202 </span>            : inline size_t SparseMat::hash(const int* idx) const
<span class="lineNum">    2203 </span>            : {
<span class="lineNum">    2204 </span>            :     size_t h = (unsigned)idx[0];
<span class="lineNum">    2205 </span>            :     if( !hdr )
<span class="lineNum">    2206 </span>            :         return 0;
<span class="lineNum">    2207 </span>            :     int i, d = hdr-&gt;dims;
<span class="lineNum">    2208 </span>            :     for( i = 1; i &lt; d; i++ )
<span class="lineNum">    2209 </span>            :         h = h*HASH_SCALE + (unsigned)idx[i];
<span class="lineNum">    2210 </span>            :     return h;
<span class="lineNum">    2211 </span>            : }
<span class="lineNum">    2212 </span>            : 
<span class="lineNum">    2213 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; SparseMat::ref(int i0, size_t* hashval)
<span class="lineNum">    2214 </span>            : { return *(_Tp*)((SparseMat*)this)-&gt;ptr(i0, true, hashval); }
<span class="lineNum">    2215 </span>            : 
<span class="lineNum">    2216 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; SparseMat::ref(int i0, int i1, size_t* hashval)
<span class="lineNum">    2217 </span>            : { return *(_Tp*)((SparseMat*)this)-&gt;ptr(i0, i1, true, hashval); }
<span class="lineNum">    2218 </span>            : 
<span class="lineNum">    2219 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; SparseMat::ref(int i0, int i1, int i2, size_t* hashval)
<span class="lineNum">    2220 </span>            : { return *(_Tp*)((SparseMat*)this)-&gt;ptr(i0, i1, i2, true, hashval); }
<span class="lineNum">    2221 </span>            : 
<span class="lineNum">    2222 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; SparseMat::ref(const int* idx, size_t* hashval)
<span class="lineNum">    2223 </span>            : { return *(_Tp*)((SparseMat*)this)-&gt;ptr(idx, true, hashval); }
<span class="lineNum">    2224 </span>            : 
<span class="lineNum">    2225 </span>            : template&lt;typename _Tp&gt; inline _Tp SparseMat::value(int i0, size_t* hashval) const
<span class="lineNum">    2226 </span>            : {
<span class="lineNum">    2227 </span>            :     const _Tp* p = (const _Tp*)((SparseMat*)this)-&gt;ptr(i0, false, hashval);
<span class="lineNum">    2228 </span>            :     return p ? *p : _Tp();
<span class="lineNum">    2229 </span>            : }
<span class="lineNum">    2230 </span>            : 
<span class="lineNum">    2231 </span>            : template&lt;typename _Tp&gt; inline _Tp SparseMat::value(int i0, int i1, size_t* hashval) const
<span class="lineNum">    2232 </span>            : {
<span class="lineNum">    2233 </span>            :     const _Tp* p = (const _Tp*)((SparseMat*)this)-&gt;ptr(i0, i1, false, hashval);
<span class="lineNum">    2234 </span>            :     return p ? *p : _Tp();
<span class="lineNum">    2235 </span>            : }
<span class="lineNum">    2236 </span>            : 
<span class="lineNum">    2237 </span>            : template&lt;typename _Tp&gt; inline _Tp SparseMat::value(int i0, int i1, int i2, size_t* hashval) const
<span class="lineNum">    2238 </span>            : {
<span class="lineNum">    2239 </span>            :     const _Tp* p = (const _Tp*)((SparseMat*)this)-&gt;ptr(i0, i1, i2, false, hashval);
<span class="lineNum">    2240 </span>            :     return p ? *p : _Tp();
<span class="lineNum">    2241 </span>            : }
<span class="lineNum">    2242 </span>            : 
<span class="lineNum">    2243 </span>            : template&lt;typename _Tp&gt; inline _Tp SparseMat::value(const int* idx, size_t* hashval) const
<span class="lineNum">    2244 </span>            : {
<span class="lineNum">    2245 </span>            :     const _Tp* p = (const _Tp*)((SparseMat*)this)-&gt;ptr(idx, false, hashval);
<span class="lineNum">    2246 </span>            :     return p ? *p : _Tp();
<span class="lineNum">    2247 </span>            : }
<span class="lineNum">    2248 </span>            : 
<span class="lineNum">    2249 </span>            : template&lt;typename _Tp&gt; inline const _Tp* SparseMat::find(int i0, size_t* hashval) const
<span class="lineNum">    2250 </span>            : { return (const _Tp*)((SparseMat*)this)-&gt;ptr(i0, false, hashval); }
<span class="lineNum">    2251 </span>            : 
<span class="lineNum">    2252 </span>            : template&lt;typename _Tp&gt; inline const _Tp* SparseMat::find(int i0, int i1, size_t* hashval) const
<span class="lineNum">    2253 </span>            : { return (const _Tp*)((SparseMat*)this)-&gt;ptr(i0, i1, false, hashval); }
<span class="lineNum">    2254 </span>            : 
<span class="lineNum">    2255 </span>            : template&lt;typename _Tp&gt; inline const _Tp* SparseMat::find(int i0, int i1, int i2, size_t* hashval) const
<span class="lineNum">    2256 </span>            : { return (const _Tp*)((SparseMat*)this)-&gt;ptr(i0, i1, i2, false, hashval); }
<span class="lineNum">    2257 </span>            : 
<span class="lineNum">    2258 </span>            : template&lt;typename _Tp&gt; inline const _Tp* SparseMat::find(const int* idx, size_t* hashval) const
<span class="lineNum">    2259 </span>            : { return (const _Tp*)((SparseMat*)this)-&gt;ptr(idx, false, hashval); }
<span class="lineNum">    2260 </span>            : 
<span class="lineNum">    2261 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; SparseMat::value(Node* n)
<span class="lineNum">    2262 </span>            : { return *(_Tp*)((uchar*)n + hdr-&gt;valueOffset); }
<span class="lineNum">    2263 </span>            : 
<span class="lineNum">    2264 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp; SparseMat::value(const Node* n) const
<span class="lineNum">    2265 </span>            : { return *(const _Tp*)((const uchar*)n + hdr-&gt;valueOffset); }
<span class="lineNum">    2266 </span>            : 
<span class="lineNum">    2267 </span>            : inline SparseMat::Node* SparseMat::node(size_t nidx)
<span class="lineNum">    2268 </span>            : { return (Node*)(void*)&amp;hdr-&gt;pool[nidx]; }
<span class="lineNum">    2269 </span>            : 
<span class="lineNum">    2270 </span>            : inline const SparseMat::Node* SparseMat::node(size_t nidx) const
<span class="lineNum">    2271 </span>            : { return (const Node*)(void*)&amp;hdr-&gt;pool[nidx]; }
<span class="lineNum">    2272 </span>            : 
<span class="lineNum">    2273 </span>            : inline SparseMatIterator SparseMat::begin()
<span class="lineNum">    2274 </span>            : { return SparseMatIterator(this); }
<span class="lineNum">    2275 </span>            : 
<span class="lineNum">    2276 </span>            : inline SparseMatConstIterator SparseMat::begin() const
<span class="lineNum">    2277 </span>            : { return SparseMatConstIterator(this); }
<span class="lineNum">    2278 </span>            : 
<span class="lineNum">    2279 </span>            : inline SparseMatIterator SparseMat::end()
<span class="lineNum">    2280 </span>            : { SparseMatIterator it(this); it.seekEnd(); return it; }
<span class="lineNum">    2281 </span>            : 
<span class="lineNum">    2282 </span>            : inline SparseMatConstIterator SparseMat::end() const
<span class="lineNum">    2283 </span>            : { SparseMatConstIterator it(this); it.seekEnd(); return it; }
<span class="lineNum">    2284 </span>            : 
<span class="lineNum">    2285 </span>            : template&lt;typename _Tp&gt; inline SparseMatIterator_&lt;_Tp&gt; SparseMat::begin()
<span class="lineNum">    2286 </span>            : { return SparseMatIterator_&lt;_Tp&gt;(this); }
<span class="lineNum">    2287 </span>            : 
<span class="lineNum">    2288 </span>            : template&lt;typename _Tp&gt; inline SparseMatConstIterator_&lt;_Tp&gt; SparseMat::begin() const
<span class="lineNum">    2289 </span>            : { return SparseMatConstIterator_&lt;_Tp&gt;(this); }
<span class="lineNum">    2290 </span>            : 
<span class="lineNum">    2291 </span>            : template&lt;typename _Tp&gt; inline SparseMatIterator_&lt;_Tp&gt; SparseMat::end()
<span class="lineNum">    2292 </span>            : { SparseMatIterator_&lt;_Tp&gt; it(this); it.seekEnd(); return it; }
<span class="lineNum">    2293 </span>            : 
<span class="lineNum">    2294 </span>            : template&lt;typename _Tp&gt; inline SparseMatConstIterator_&lt;_Tp&gt; SparseMat::end() const
<span class="lineNum">    2295 </span>            : { SparseMatConstIterator_&lt;_Tp&gt; it(this); it.seekEnd(); return it; }
<span class="lineNum">    2296 </span>            : 
<span class="lineNum">    2297 </span>            : 
<span class="lineNum">    2298 </span>            : inline SparseMatConstIterator::SparseMatConstIterator()
<span class="lineNum">    2299 </span>            : : m(0), hashidx(0), ptr(0)
<span class="lineNum">    2300 </span>            : {
<span class="lineNum">    2301 </span>            : }
<span class="lineNum">    2302 </span>            : 
<span class="lineNum">    2303 </span>            : inline SparseMatConstIterator::SparseMatConstIterator(const SparseMatConstIterator&amp; it)
<span class="lineNum">    2304 </span>            : : m(it.m), hashidx(it.hashidx), ptr(it.ptr)
<span class="lineNum">    2305 </span>            : {
<span class="lineNum">    2306 </span>            : }
<span class="lineNum">    2307 </span>            : 
<span class="lineNum">    2308 </span>            : static inline bool operator == (const SparseMatConstIterator&amp; it1, const SparseMatConstIterator&amp; it2)
<span class="lineNum">    2309 </span>            : { return it1.m == it2.m &amp;&amp; it1.ptr == it2.ptr; }
<span class="lineNum">    2310 </span>            : 
<span class="lineNum">    2311 </span>            : static inline bool operator != (const SparseMatConstIterator&amp; it1, const SparseMatConstIterator&amp; it2)
<span class="lineNum">    2312 </span>            : { return !(it1 == it2); }
<span class="lineNum">    2313 </span>            : 
<span class="lineNum">    2314 </span>            : 
<span class="lineNum">    2315 </span>            : inline SparseMatConstIterator&amp; SparseMatConstIterator::operator = (const SparseMatConstIterator&amp; it)
<span class="lineNum">    2316 </span>            : {
<span class="lineNum">    2317 </span>            :     if( this != &amp;it )
<span class="lineNum">    2318 </span>            :     {
<span class="lineNum">    2319 </span>            :         m = it.m;
<span class="lineNum">    2320 </span>            :         hashidx = it.hashidx;
<span class="lineNum">    2321 </span>            :         ptr = it.ptr;
<span class="lineNum">    2322 </span>            :     }
<span class="lineNum">    2323 </span>            :     return *this;
<span class="lineNum">    2324 </span>            : }
<span class="lineNum">    2325 </span>            : 
<span class="lineNum">    2326 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp; SparseMatConstIterator::value() const
<span class="lineNum">    2327 </span>            : { return *(_Tp*)ptr; }
<span class="lineNum">    2328 </span>            : 
<span class="lineNum">    2329 </span>            : inline const SparseMat::Node* SparseMatConstIterator::node() const
<span class="lineNum">    2330 </span>            : {
<span class="lineNum">    2331 </span>            :     return ptr &amp;&amp; m &amp;&amp; m-&gt;hdr ?
<span class="lineNum">    2332 </span>            :         (const SparseMat::Node*)(void*)(ptr - m-&gt;hdr-&gt;valueOffset) : 0;
<span class="lineNum">    2333 </span>            : }
<span class="lineNum">    2334 </span>            : 
<span class="lineNum">    2335 </span>            : inline SparseMatConstIterator SparseMatConstIterator::operator ++(int)
<span class="lineNum">    2336 </span>            : {
<span class="lineNum">    2337 </span>            :     SparseMatConstIterator it = *this;
<span class="lineNum">    2338 </span>            :     ++*this;
<span class="lineNum">    2339 </span>            :     return it;
<span class="lineNum">    2340 </span>            : }
<span class="lineNum">    2341 </span>            : 
<span class="lineNum">    2342 </span>            : 
<span class="lineNum">    2343 </span>            : inline void SparseMatConstIterator::seekEnd()
<span class="lineNum">    2344 </span>            : {
<span class="lineNum">    2345 </span>            :     if( m &amp;&amp; m-&gt;hdr )
<span class="lineNum">    2346 </span>            :     {
<span class="lineNum">    2347 </span>            :         hashidx = m-&gt;hdr-&gt;hashtab.size();
<span class="lineNum">    2348 </span>            :         ptr = 0;
<span class="lineNum">    2349 </span>            :     }
<span class="lineNum">    2350 </span>            : }
<span class="lineNum">    2351 </span>            : 
<span class="lineNum">    2352 </span>            : inline SparseMatIterator::SparseMatIterator()
<span class="lineNum">    2353 </span>            : {}
<span class="lineNum">    2354 </span>            : 
<span class="lineNum">    2355 </span>            : inline SparseMatIterator::SparseMatIterator(SparseMat* _m)
<span class="lineNum">    2356 </span>            : : SparseMatConstIterator(_m)
<span class="lineNum">    2357 </span>            : {}
<span class="lineNum">    2358 </span>            : 
<span class="lineNum">    2359 </span>            : inline SparseMatIterator::SparseMatIterator(const SparseMatIterator&amp; it)
<span class="lineNum">    2360 </span>            : : SparseMatConstIterator(it)
<span class="lineNum">    2361 </span>            : {
<span class="lineNum">    2362 </span>            : }
<span class="lineNum">    2363 </span>            : 
<span class="lineNum">    2364 </span>            : inline SparseMatIterator&amp; SparseMatIterator::operator = (const SparseMatIterator&amp; it)
<span class="lineNum">    2365 </span>            : {
<span class="lineNum">    2366 </span>            :     (SparseMatConstIterator&amp;)*this = it;
<span class="lineNum">    2367 </span>            :     return *this;
<span class="lineNum">    2368 </span>            : }
<span class="lineNum">    2369 </span>            : 
<span class="lineNum">    2370 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp; SparseMatIterator::value() const
<span class="lineNum">    2371 </span>            : { return *(_Tp*)ptr; }
<span class="lineNum">    2372 </span>            : 
<span class="lineNum">    2373 </span>            : inline SparseMat::Node* SparseMatIterator::node() const
<span class="lineNum">    2374 </span>            : {
<span class="lineNum">    2375 </span>            :     return (SparseMat::Node*)SparseMatConstIterator::node();
<span class="lineNum">    2376 </span>            : }
<span class="lineNum">    2377 </span>            : 
<span class="lineNum">    2378 </span>            : inline SparseMatIterator&amp; SparseMatIterator::operator ++()
<span class="lineNum">    2379 </span>            : {
<span class="lineNum">    2380 </span>            :     SparseMatConstIterator::operator ++();
<span class="lineNum">    2381 </span>            :     return *this;
<span class="lineNum">    2382 </span>            : }
<span class="lineNum">    2383 </span>            : 
<span class="lineNum">    2384 </span>            : inline SparseMatIterator SparseMatIterator::operator ++(int)
<span class="lineNum">    2385 </span>            : {
<span class="lineNum">    2386 </span>            :     SparseMatIterator it = *this;
<span class="lineNum">    2387 </span>            :     ++*this;
<span class="lineNum">    2388 </span>            :     return it;
<span class="lineNum">    2389 </span>            : }
<span class="lineNum">    2390 </span>            : 
<span class="lineNum">    2391 </span>            : 
<span class="lineNum">    2392 </span>            : template&lt;typename _Tp&gt; inline SparseMat_&lt;_Tp&gt;::SparseMat_()
<span class="lineNum">    2393 </span>            : { flags = MAGIC_VAL | DataType&lt;_Tp&gt;::type; }
<span class="lineNum">    2394 </span>            : 
<span class="lineNum">    2395 </span>            : template&lt;typename _Tp&gt; inline SparseMat_&lt;_Tp&gt;::SparseMat_(int _dims, const int* _sizes)
<span class="lineNum">    2396 </span>            : : SparseMat(_dims, _sizes, DataType&lt;_Tp&gt;::type)
<span class="lineNum">    2397 </span>            : {}
<span class="lineNum">    2398 </span>            : 
<span class="lineNum">    2399 </span>            : template&lt;typename _Tp&gt; inline SparseMat_&lt;_Tp&gt;::SparseMat_(const SparseMat&amp; m)
<span class="lineNum">    2400 </span>            : {
<span class="lineNum">    2401 </span>            :     if( m.type() == DataType&lt;_Tp&gt;::type )
<span class="lineNum">    2402 </span>            :         *this = (const SparseMat_&lt;_Tp&gt;&amp;)m;
<span class="lineNum">    2403 </span>            :     else
<span class="lineNum">    2404 </span>            :         m.convertTo(*this, DataType&lt;_Tp&gt;::type);
<span class="lineNum">    2405 </span>            : }
<span class="lineNum">    2406 </span>            : 
<span class="lineNum">    2407 </span>            : template&lt;typename _Tp&gt; inline SparseMat_&lt;_Tp&gt;::SparseMat_(const SparseMat_&lt;_Tp&gt;&amp; m)
<span class="lineNum">    2408 </span>            : {
<span class="lineNum">    2409 </span>            :     this-&gt;flags = m.flags;
<span class="lineNum">    2410 </span>            :     this-&gt;hdr = m.hdr;
<span class="lineNum">    2411 </span>            :     if( this-&gt;hdr )
<span class="lineNum">    2412 </span>            :         CV_XADD(&amp;this-&gt;hdr-&gt;refcount, 1);
<span class="lineNum">    2413 </span>            : }
<span class="lineNum">    2414 </span>            : 
<span class="lineNum">    2415 </span>            : template&lt;typename _Tp&gt; inline SparseMat_&lt;_Tp&gt;::SparseMat_(const Mat&amp; m)
<span class="lineNum">    2416 </span>            : {
<span class="lineNum">    2417 </span>            :     SparseMat sm(m);
<span class="lineNum">    2418 </span>            :     *this = sm;
<span class="lineNum">    2419 </span>            : }
<span class="lineNum">    2420 </span>            : 
<span class="lineNum">    2421 </span>            : template&lt;typename _Tp&gt; inline SparseMat_&lt;_Tp&gt;::SparseMat_(const CvSparseMat* m)
<span class="lineNum">    2422 </span>            : {
<span class="lineNum">    2423 </span>            :     SparseMat sm(m);
<span class="lineNum">    2424 </span>            :     *this = sm;
<span class="lineNum">    2425 </span>            : }
<span class="lineNum">    2426 </span>            : 
<span class="lineNum">    2427 </span>            : template&lt;typename _Tp&gt; inline SparseMat_&lt;_Tp&gt;&amp;
<span class="lineNum">    2428 </span>            : SparseMat_&lt;_Tp&gt;::operator = (const SparseMat_&lt;_Tp&gt;&amp; m)
<span class="lineNum">    2429 </span>            : {
<span class="lineNum">    2430 </span>            :     if( this != &amp;m )
<span class="lineNum">    2431 </span>            :     {
<span class="lineNum">    2432 </span>            :         if( m.hdr ) CV_XADD(&amp;m.hdr-&gt;refcount, 1);
<span class="lineNum">    2433 </span>            :         release();
<span class="lineNum">    2434 </span>            :         flags = m.flags;
<span class="lineNum">    2435 </span>            :         hdr = m.hdr;
<span class="lineNum">    2436 </span>            :     }
<span class="lineNum">    2437 </span>            :     return *this;
<span class="lineNum">    2438 </span>            : }
<span class="lineNum">    2439 </span>            : 
<span class="lineNum">    2440 </span>            : template&lt;typename _Tp&gt; inline SparseMat_&lt;_Tp&gt;&amp;
<span class="lineNum">    2441 </span>            : SparseMat_&lt;_Tp&gt;::operator = (const SparseMat&amp; m)
<span class="lineNum">    2442 </span>            : {
<span class="lineNum">    2443 </span>            :     if( m.type() == DataType&lt;_Tp&gt;::type )
<span class="lineNum">    2444 </span>            :         return (*this = (const SparseMat_&lt;_Tp&gt;&amp;)m);
<span class="lineNum">    2445 </span>            :     m.convertTo(*this, DataType&lt;_Tp&gt;::type);
<span class="lineNum">    2446 </span>            :     return *this;
<span class="lineNum">    2447 </span>            : }
<span class="lineNum">    2448 </span>            : 
<span class="lineNum">    2449 </span>            : template&lt;typename _Tp&gt; inline SparseMat_&lt;_Tp&gt;&amp;
<span class="lineNum">    2450 </span>            : SparseMat_&lt;_Tp&gt;::operator = (const Mat&amp; m)
<span class="lineNum">    2451 </span>            : { return (*this = SparseMat(m)); }
<span class="lineNum">    2452 </span>            : 
<span class="lineNum">    2453 </span>            : template&lt;typename _Tp&gt; inline SparseMat_&lt;_Tp&gt;
<span class="lineNum">    2454 </span>            : SparseMat_&lt;_Tp&gt;::clone() const
<span class="lineNum">    2455 </span>            : {
<span class="lineNum">    2456 </span>            :     SparseMat_&lt;_Tp&gt; m;
<span class="lineNum">    2457 </span>            :     this-&gt;copyTo(m);
<span class="lineNum">    2458 </span>            :     return m;
<span class="lineNum">    2459 </span>            : }
<span class="lineNum">    2460 </span>            : 
<span class="lineNum">    2461 </span>            : template&lt;typename _Tp&gt; inline void
<span class="lineNum">    2462 </span>            : SparseMat_&lt;_Tp&gt;::create(int _dims, const int* _sizes)
<span class="lineNum">    2463 </span>            : {
<span class="lineNum">    2464 </span>            :     SparseMat::create(_dims, _sizes, DataType&lt;_Tp&gt;::type);
<span class="lineNum">    2465 </span>            : }
<span class="lineNum">    2466 </span>            : 
<span class="lineNum">    2467 </span>            : template&lt;typename _Tp&gt; inline
<span class="lineNum">    2468 </span>            : SparseMat_&lt;_Tp&gt;::operator CvSparseMat*() const
<span class="lineNum">    2469 </span>            : {
<span class="lineNum">    2470 </span>            :     return SparseMat::operator CvSparseMat*();
<span class="lineNum">    2471 </span>            : }
<span class="lineNum">    2472 </span>            : 
<span class="lineNum">    2473 </span>            : template&lt;typename _Tp&gt; inline int SparseMat_&lt;_Tp&gt;::type() const
<span class="lineNum">    2474 </span>            : { return DataType&lt;_Tp&gt;::type; }
<span class="lineNum">    2475 </span>            : 
<span class="lineNum">    2476 </span>            : template&lt;typename _Tp&gt; inline int SparseMat_&lt;_Tp&gt;::depth() const
<span class="lineNum">    2477 </span>            : { return DataType&lt;_Tp&gt;::depth; }
<span class="lineNum">    2478 </span>            : 
<span class="lineNum">    2479 </span>            : template&lt;typename _Tp&gt; inline int SparseMat_&lt;_Tp&gt;::channels() const
<span class="lineNum">    2480 </span>            : { return DataType&lt;_Tp&gt;::channels; }
<span class="lineNum">    2481 </span>            : 
<span class="lineNum">    2482 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp;
<span class="lineNum">    2483 </span>            : SparseMat_&lt;_Tp&gt;::ref(int i0, size_t* hashval)
<span class="lineNum">    2484 </span>            : { return SparseMat::ref&lt;_Tp&gt;(i0, hashval); }
<span class="lineNum">    2485 </span>            : 
<span class="lineNum">    2486 </span>            : template&lt;typename _Tp&gt; inline _Tp
<span class="lineNum">    2487 </span>            : SparseMat_&lt;_Tp&gt;::operator()(int i0, size_t* hashval) const
<span class="lineNum">    2488 </span>            : { return SparseMat::value&lt;_Tp&gt;(i0, hashval); }
<span class="lineNum">    2489 </span>            : 
<span class="lineNum">    2490 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp;
<span class="lineNum">    2491 </span>            : SparseMat_&lt;_Tp&gt;::ref(int i0, int i1, size_t* hashval)
<span class="lineNum">    2492 </span>            : { return SparseMat::ref&lt;_Tp&gt;(i0, i1, hashval); }
<span class="lineNum">    2493 </span>            : 
<span class="lineNum">    2494 </span>            : template&lt;typename _Tp&gt; inline _Tp
<span class="lineNum">    2495 </span>            : SparseMat_&lt;_Tp&gt;::operator()(int i0, int i1, size_t* hashval) const
<span class="lineNum">    2496 </span>            : { return SparseMat::value&lt;_Tp&gt;(i0, i1, hashval); }
<span class="lineNum">    2497 </span>            : 
<span class="lineNum">    2498 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp;
<span class="lineNum">    2499 </span>            : SparseMat_&lt;_Tp&gt;::ref(int i0, int i1, int i2, size_t* hashval)
<span class="lineNum">    2500 </span>            : { return SparseMat::ref&lt;_Tp&gt;(i0, i1, i2, hashval); }
<span class="lineNum">    2501 </span>            : 
<span class="lineNum">    2502 </span>            : template&lt;typename _Tp&gt; inline _Tp
<span class="lineNum">    2503 </span>            : SparseMat_&lt;_Tp&gt;::operator()(int i0, int i1, int i2, size_t* hashval) const
<span class="lineNum">    2504 </span>            : { return SparseMat::value&lt;_Tp&gt;(i0, i1, i2, hashval); }
<span class="lineNum">    2505 </span>            : 
<span class="lineNum">    2506 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp;
<span class="lineNum">    2507 </span>            : SparseMat_&lt;_Tp&gt;::ref(const int* idx, size_t* hashval)
<span class="lineNum">    2508 </span>            : { return SparseMat::ref&lt;_Tp&gt;(idx, hashval); }
<span class="lineNum">    2509 </span>            : 
<span class="lineNum">    2510 </span>            : template&lt;typename _Tp&gt; inline _Tp
<span class="lineNum">    2511 </span>            : SparseMat_&lt;_Tp&gt;::operator()(const int* idx, size_t* hashval) const
<span class="lineNum">    2512 </span>            : { return SparseMat::value&lt;_Tp&gt;(idx, hashval); }
<span class="lineNum">    2513 </span>            : 
<span class="lineNum">    2514 </span>            : template&lt;typename _Tp&gt; inline SparseMatIterator_&lt;_Tp&gt; SparseMat_&lt;_Tp&gt;::begin()
<span class="lineNum">    2515 </span>            : { return SparseMatIterator_&lt;_Tp&gt;(this); }
<span class="lineNum">    2516 </span>            : 
<span class="lineNum">    2517 </span>            : template&lt;typename _Tp&gt; inline SparseMatConstIterator_&lt;_Tp&gt; SparseMat_&lt;_Tp&gt;::begin() const
<span class="lineNum">    2518 </span>            : { return SparseMatConstIterator_&lt;_Tp&gt;(this); }
<span class="lineNum">    2519 </span>            : 
<span class="lineNum">    2520 </span>            : template&lt;typename _Tp&gt; inline SparseMatIterator_&lt;_Tp&gt; SparseMat_&lt;_Tp&gt;::end()
<span class="lineNum">    2521 </span>            : { SparseMatIterator_&lt;_Tp&gt; it(this); it.seekEnd(); return it; }
<span class="lineNum">    2522 </span>            : 
<span class="lineNum">    2523 </span>            : template&lt;typename _Tp&gt; inline SparseMatConstIterator_&lt;_Tp&gt; SparseMat_&lt;_Tp&gt;::end() const
<span class="lineNum">    2524 </span>            : { SparseMatConstIterator_&lt;_Tp&gt; it(this); it.seekEnd(); return it; }
<span class="lineNum">    2525 </span>            : 
<span class="lineNum">    2526 </span>            : template&lt;typename _Tp&gt; inline
<span class="lineNum">    2527 </span>            : SparseMatConstIterator_&lt;_Tp&gt;::SparseMatConstIterator_()
<span class="lineNum">    2528 </span>            : {}
<span class="lineNum">    2529 </span>            : 
<span class="lineNum">    2530 </span>            : template&lt;typename _Tp&gt; inline
<span class="lineNum">    2531 </span>            : SparseMatConstIterator_&lt;_Tp&gt;::SparseMatConstIterator_(const SparseMat_&lt;_Tp&gt;* _m)
<span class="lineNum">    2532 </span>            : : SparseMatConstIterator(_m)
<span class="lineNum">    2533 </span>            : {}
<span class="lineNum">    2534 </span>            : 
<span class="lineNum">    2535 </span>            : template&lt;typename _Tp&gt; inline
<span class="lineNum">    2536 </span>            : SparseMatConstIterator_&lt;_Tp&gt;::SparseMatConstIterator_(const SparseMat* _m)
<span class="lineNum">    2537 </span>            : : SparseMatConstIterator(_m)
<span class="lineNum">    2538 </span>            : {
<span class="lineNum">    2539 </span>            :     CV_Assert( _m-&gt;type() == DataType&lt;_Tp&gt;::type );
<span class="lineNum">    2540 </span>            : }
<span class="lineNum">    2541 </span>            : 
<span class="lineNum">    2542 </span>            : template&lt;typename _Tp&gt; inline
<span class="lineNum">    2543 </span>            : SparseMatConstIterator_&lt;_Tp&gt;::SparseMatConstIterator_(const SparseMatConstIterator_&lt;_Tp&gt;&amp; it)
<span class="lineNum">    2544 </span>            : : SparseMatConstIterator(it)
<span class="lineNum">    2545 </span>            : {}
<span class="lineNum">    2546 </span>            : 
<span class="lineNum">    2547 </span>            : template&lt;typename _Tp&gt; inline SparseMatConstIterator_&lt;_Tp&gt;&amp;
<span class="lineNum">    2548 </span>            : SparseMatConstIterator_&lt;_Tp&gt;::operator = (const SparseMatConstIterator_&lt;_Tp&gt;&amp; it)
<span class="lineNum">    2549 </span>            : { return reinterpret_cast&lt;SparseMatConstIterator_&lt;_Tp&gt;&amp;&gt;
<span class="lineNum">    2550 </span>            :     (*reinterpret_cast&lt;SparseMatConstIterator*&gt;(this) =
<span class="lineNum">    2551 </span>            :      reinterpret_cast&lt;const SparseMatConstIterator&amp;&gt;(it)); }
<span class="lineNum">    2552 </span>            : 
<span class="lineNum">    2553 </span>            : template&lt;typename _Tp&gt; inline const _Tp&amp;
<span class="lineNum">    2554 </span>            : SparseMatConstIterator_&lt;_Tp&gt;::operator *() const
<span class="lineNum">    2555 </span>            : { return *(const _Tp*)this-&gt;ptr; }
<span class="lineNum">    2556 </span>            : 
<span class="lineNum">    2557 </span>            : template&lt;typename _Tp&gt; inline SparseMatConstIterator_&lt;_Tp&gt;&amp;
<span class="lineNum">    2558 </span>            : SparseMatConstIterator_&lt;_Tp&gt;::operator ++()
<span class="lineNum">    2559 </span>            : {
<span class="lineNum">    2560 </span>            :     SparseMatConstIterator::operator ++();
<span class="lineNum">    2561 </span>            :     return *this;
<span class="lineNum">    2562 </span>            : }
<span class="lineNum">    2563 </span>            : 
<span class="lineNum">    2564 </span>            : template&lt;typename _Tp&gt; inline SparseMatConstIterator_&lt;_Tp&gt;
<span class="lineNum">    2565 </span>            : SparseMatConstIterator_&lt;_Tp&gt;::operator ++(int)
<span class="lineNum">    2566 </span>            : {
<span class="lineNum">    2567 </span>            :     SparseMatConstIterator it = *this;
<span class="lineNum">    2568 </span>            :     SparseMatConstIterator::operator ++();
<span class="lineNum">    2569 </span>            :     return it;
<span class="lineNum">    2570 </span>            : }
<span class="lineNum">    2571 </span>            : 
<span class="lineNum">    2572 </span>            : template&lt;typename _Tp&gt; inline
<span class="lineNum">    2573 </span>            : SparseMatIterator_&lt;_Tp&gt;::SparseMatIterator_()
<span class="lineNum">    2574 </span>            : {}
<span class="lineNum">    2575 </span>            : 
<span class="lineNum">    2576 </span>            : template&lt;typename _Tp&gt; inline
<span class="lineNum">    2577 </span>            : SparseMatIterator_&lt;_Tp&gt;::SparseMatIterator_(SparseMat_&lt;_Tp&gt;* _m)
<span class="lineNum">    2578 </span>            : : SparseMatConstIterator_&lt;_Tp&gt;(_m)
<span class="lineNum">    2579 </span>            : {}
<span class="lineNum">    2580 </span>            : 
<span class="lineNum">    2581 </span>            : template&lt;typename _Tp&gt; inline
<span class="lineNum">    2582 </span>            : SparseMatIterator_&lt;_Tp&gt;::SparseMatIterator_(SparseMat* _m)
<span class="lineNum">    2583 </span>            : : SparseMatConstIterator_&lt;_Tp&gt;(_m)
<span class="lineNum">    2584 </span>            : {}
<span class="lineNum">    2585 </span>            : 
<span class="lineNum">    2586 </span>            : template&lt;typename _Tp&gt; inline
<span class="lineNum">    2587 </span>            : SparseMatIterator_&lt;_Tp&gt;::SparseMatIterator_(const SparseMatIterator_&lt;_Tp&gt;&amp; it)
<span class="lineNum">    2588 </span>            : : SparseMatConstIterator_&lt;_Tp&gt;(it)
<span class="lineNum">    2589 </span>            : {}
<span class="lineNum">    2590 </span>            : 
<span class="lineNum">    2591 </span>            : template&lt;typename _Tp&gt; inline SparseMatIterator_&lt;_Tp&gt;&amp;
<span class="lineNum">    2592 </span>            : SparseMatIterator_&lt;_Tp&gt;::operator = (const SparseMatIterator_&lt;_Tp&gt;&amp; it)
<span class="lineNum">    2593 </span>            : { return reinterpret_cast&lt;SparseMatIterator_&lt;_Tp&gt;&amp;&gt;
<span class="lineNum">    2594 </span>            :     (*reinterpret_cast&lt;SparseMatConstIterator*&gt;(this) =
<span class="lineNum">    2595 </span>            :      reinterpret_cast&lt;const SparseMatConstIterator&amp;&gt;(it)); }
<span class="lineNum">    2596 </span>            : 
<span class="lineNum">    2597 </span>            : template&lt;typename _Tp&gt; inline _Tp&amp;
<span class="lineNum">    2598 </span>            : SparseMatIterator_&lt;_Tp&gt;::operator *() const
<span class="lineNum">    2599 </span>            : { return *(_Tp*)this-&gt;ptr; }
<span class="lineNum">    2600 </span>            : 
<span class="lineNum">    2601 </span>            : template&lt;typename _Tp&gt; inline SparseMatIterator_&lt;_Tp&gt;&amp;
<span class="lineNum">    2602 </span>            : SparseMatIterator_&lt;_Tp&gt;::operator ++()
<span class="lineNum">    2603 </span>            : {
<span class="lineNum">    2604 </span>            :     SparseMatConstIterator::operator ++();
<span class="lineNum">    2605 </span>            :     return *this;
<span class="lineNum">    2606 </span>            : }
<span class="lineNum">    2607 </span>            : 
<span class="lineNum">    2608 </span>            : template&lt;typename _Tp&gt; inline SparseMatIterator_&lt;_Tp&gt;
<span class="lineNum">    2609 </span>            : SparseMatIterator_&lt;_Tp&gt;::operator ++(int)
<span class="lineNum">    2610 </span>            : {
<span class="lineNum">    2611 </span>            :     SparseMatIterator it = *this;
<span class="lineNum">    2612 </span>            :     SparseMatConstIterator::operator ++();
<span class="lineNum">    2613 </span>            :     return it;
<span class="lineNum">    2614 </span>            : }
<span class="lineNum">    2615 </span>            : 
<span class="lineNum">    2616 </span>            : }
<span class="lineNum">    2617 </span>            : 
<span class="lineNum">    2618 </span>            : #endif
<span class="lineNum">    2619 </span>            : #endif
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
